Activating/stopping an idle watcher in a prepare/check callback

Gabriel Kerneis kerneis at
Fri Dec 4 14:07:18 CET 2009


On Fri, Dec 04, 2009 at 12:13:42PM +0100, Marc Lehmann wrote:
> > - if I activate a (previously inactive) idle watcher in a *prepare*
> >   callback, then the associated callback will be called during the
> >   *current* loop iteration (provided there is nothing else to do of
> >   higher priority).
> No, nothing will be called after prepare, before we go to the next loop
> iteration (after the blocking call).

I think we do not have the same definition of an iteration (for me, it
starts at the step (*), in the documentation of ev_loop, whereas for you
it starts after a blocking call).

> idle watchers, however, will keep the event loop from blocking
> indefinitely when started, even in a prepare watcher.

So in that case, the "blocking" call will collect new I/O events if any,
but will not block at all (since we activated an idle watcher - assuming
this a watcher of highest priority).  Is that correct or do I still
misunderstand something about how libev loop works?

> > - if I stop a (pending) watcher at any time (even in an I/O callback,
> >   e.g.), the associated callback will not be called (i.e., this is as if
> >   the event which triggered the stopped watcher never happened).
> No, only the pending watcher will be stopped (and taken out of pending
> state) - other watchers for the same event will still run, the event still
> happened.

Of course (I had in mind stopping an idle watcher, hence my mistake).

Thank you very much,
Gabriel Kerneis

More information about the libev mailing list