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

Marc Lehmann schmorp at
Fri Dec 4 15:08:47 CET 2009

On Fri, Dec 04, 2009 at 02:07:18PM +0100, Gabriel Kerneis <kerneis at> wrote:
> > 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).

Ok - but note that my "idea" is aligned with the code.

The iteration starts when the event loop starts running and stops when
it is blocking again (call ev_loop_count for example). This is, in my
personal experience, quite aligned with how people expect things to work,
but indeed it is not mentioned explicitly.

> > 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?

That's correct - as long as idle watchers are active, libev will not delay
artificially, and they can be started effectively anytime (as long as it
is synchronous to the event loop).

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

More information about the libev mailing list