Correctly pass watcher to another loop

Marc Lehmann schmorp at
Sun Jun 24 14:53:43 CEST 2012

On Sun, Jun 24, 2012 at 04:10:41PM +0400, Vladimir Afinello < at> wrote:
> I pass a group of watchers at a time (at least 5), so at this moment I'm in
> a callback of a one of that watchers.

That is no problem - after you stop() a watcher the loop will not access
it in any way anymore.

> Should I wake the current thread loop to perform stop() on the other
> watchers in a group?

I am not sure what that means, but again, if the watchers are stopped,
then the loop will no longer access them.

> I thought, the loop isn't in a wait state at that time since the callback
> is executed.

The loop state is safely serialised to memory while a watcher callback is
executed. Basically, when you are inside a callback, you are in the same
state as code running outside the loop.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list