Sorry for yet another top post.
This answer is confused, it only shows the size of the defer queue. There is currently no way to easily expose the size of the waiting callbacks in each tick.
> 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
> --
> You received this message because you are subscribed to the Google Groups "EventMachine" group.
> To post to this group, send email to eventmachine@googlegroups.com.
> To unsubscribe from this group, send email to eventmachine+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/eventmachine?hl=en.