On Thu, Nov 08, 2007 at 04:35:13PM -0500, Nick Mathewson <[EMAIL PROTECTED]> 
wrote:
> The main advantage to using event_active() for activating events
> rather than calling the callback directly is that you don't need to
> worry about call loops.  In other words, if event A's callback
> sometimes calls event_active(B), and B's callback sometimes calls
> event_active(A), you don't need to worry about stack overflow.

Not quite: it would not really prevent loops at all, and since the stack
overflows due to a _very_ deep recursion this would likely be a bug even
with event_activate (but might not get detected properly with it except
by using a lot of additional cpu), so this use case isn't something to go
for, it only hides bugs.

In any case, this is now supported by the emulation layer as long as only
the known event types are being used.

> Also, if you have a lot of events to service, and some of them
> will get activated by libevent and some of them will get activated
> manually, using event_active() ensures that you don't starve the
> libevent-activated events while all of the other events are calling
> each other's callbacks.
> 
> (That's Tor's use-case for this, at any rate.)

By combining events, I see. Ok, that makes more sense, althoguh I think
the API (in libev) is less than nice for this.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [EMAIL PROTECTED]
      -=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to