Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Created January 27, 2012 03:18
Show Gist options
  • Select an option

  • Save kwilczynski/1686778 to your computer and use it in GitHub Desktop.

Select an option

Save kwilczynski/1686778 to your computer and use it in GitHub Desktop.
Accessing EventMachine internal queues -- when working with defer ...
module EventMachine
def self.threadqueue
@threadqueue
end
def self.resultqueue
@resultqueue
end
end
EventMachine.run do
EventMachine.threadpool_size = 1
EM.add_periodic_timer(1) do
p [EventMachine.threadqueue.size,
EventMachine.resultqueue.size,
EventMachine.threadqueue.num_waiting]
end
4.times do
EventMachine.defer(Proc.new { sleep 5 }, Proc.new { p 'DONE' })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment