--- libev/ev.html 2007/12/08 15:30:29 1.72 +++ libev/ev.html 2007/12/08 22:11:14 1.73 @@ -6,7 +6,7 @@ - + @@ -531,8 +531,9 @@ libev watchers. However, a pair of ev_prepare/ev_check watchers is usually a better approach for this kind of thing.

Here are the gory details of what ev_loop does:

-
   * If there are no active watchers (reference count is zero), return.
-   - Queue prepare watchers and then call all outstanding watchers.
+
   - Before the first iteration, call any pending watchers.
+   * If there are no active watchers (reference count is zero), return.
+   - Queue all prepare watchers and then call all outstanding watchers.
    - If we have been forked, recreate the kernel state.
    - Update the kernel state with all outstanding changes.
    - Update the "event loop time".
@@ -1485,6 +1486,15 @@
 of lower priority, but only once, using idle watchers to keep the event
 loop from blocking if lower-priority coroutines are active, thus mapping
 low-priority coroutines to idle/background tasks).

+

It is recommended to give ev_check watchers highest (EV_MAXPRI) +priority, to ensure that they are being run before any other watchers +after the poll. Also, ev_check watchers (and ev_prepare watchers, +too) should not activate ("feed") events into libev. While libev fully +supports this, they will be called before other ev_check watchers did +their job. As ev_check watchers are often used to embed other event +loops those other event loops might be in an unusable state until their +ev_check watcher ran (always remind yourself to coexist peacefully with +others).

ev_prepare_init (ev_prepare *, callback)
ev_check_init (ev_check *, callback)