Hi Brian,
I guess, you have probably already figured this out, but in case you
were not ...
> I was hoping to determine how many callbacks had been queued up
> (scheduled?) in the main reactor.
Since, its Ruby you can monkey-patch to expose internal queues:
module EventMachine
def self.threadqueue
@threadqueue
end
def self.resultqueue
@resultqueue
end
end
But this is probably not advisable (citation needed), etc.
> I saw EventMachine::Queue.size but it looks like this is not a class
> method, and can only be called on an instance of that class. (maybe
> some special queue object?)
EventMachine::Queue is something completely different as you have
noticed.
> What's the best way to get the queue size of the main reactor?
Once you have monkey-patch in place, then for example:
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
I hope that helps :-)
P.S. For the API of Queue, check Ruby's documentation.
KW