Optimal multithread model

Marc Lehmann schmorp at schmorp.de
Mon Mar 15 16:56:38 CET 2010

On Mon, Mar 15, 2010 at 02:58:14PM +0100, Christophe Meessen <christophe at meessen.net> wrote:
>> When you can't use a more efficient process model
>> and for some reason *have* to use threads, a lader/follower pattern, or
>> multiple event loops, are usually more preferable. YMMV.
> The pattern I describe is the leader/follower pattern. I just learned it  
> was called like that :)

Yeah, after re-reading your e-mail and additional explanations, it seems
like that.

> Is the suggested use of ev_loop( ONE_SHOT ) ok to implement this pattern  
> or is there a better way ?

I would experiment by simply handing the event loop to the next
thread in each callback, and acquiring the loop back once finished
(stopping/starting of watchers is required here).

That way your callbacks would compete for the event loop, and the event
loop would only poll once all current callbacks have been invoked - before
each (or each slow) callback, the event loop would be passed to the next

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list