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

Marc Lehmann schmorp at schmorp.de
Fri Dec 4 12:13:42 CET 2009


On Fri, Dec 04, 2009 at 09:52:23AM +0100, Gabriel Kerneis <kerneis at pps.jussieu.fr> 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).

idle watchers will always be called first at the beginning of a new
iteration.

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

> - if I activate a (previously inactive) idle watcher in a *check*
>   callback, then the associated callback will be called during the
>   *next* loop iteration (provided there is nothing else to do of higher
>   priority during the next iteration).

Yes - the event loop detects whether it is "idle" before it executes the
pending callbacks.

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

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



More information about the libev mailing list