Hi,

I am evaluating implementing a leader/follower pattern for multiplexing threads 
over a 
single libev event_loop, ala ACE_Reactor. I have decided against using the 
defualt_event_loop 
for the thread pool as it is too concerned with signals etc...

My plan is to protect a shared event_loop with a mutex of some kind so that 
only the leader
blocks waiting.  When events are signalled, the handlers record the filehandle 
that is ready
in some way, then release the mutex, this allows the next waiting thread to 
enter the loop,
and the current thread then processes the set of ready filehandles.  In order 
to get the 
performance benefit of the leader/follower pattern, the leader must remove the 
signalled handles
from the event loop prior to releasing the mutex, and then inform the currently 
blocking thread
at a later time when processing has completed, so that the removed filehandles 
can be reinserted.

This raises a question: What is the most efficient way to 'disable' and 
're-enable' event watchers?
Do I simply add and remove them each time they are signalled, or will this 
cause lots of heap churn?
Is there a simple 'disable' ev_XXX_set() I can call (I can't see one... but I 
am not sure what the 
active flag is designed for).

Also, is there a convenient/efficient way to iterate over the complete set of 
watchers (active) or 
will I have to implement some kind of index to enable a posted ev_async call to 
reenable the watchers?

Again, does anyone have any recommendations over how to construct the main 
blocking loop: Do I either 
use prepare/check watchers around a repeating loop, or an outer for(;;) 
containing a loop_once() ?

Any comments or ideas greatfully received!

Rick Taylor

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to