--- libev/ev.pod 2008/07/08 09:49:15 1.171 +++ libev/ev.pod 2008/09/08 17:24:39 1.176 @@ -575,6 +575,18 @@ time used for relative timers. You can treat it as the timestamp of the event occurring (or more correctly, libev finding out about it). +=item ev_now_update (loop) + +Establishes the current time by querying the kernel, updating the time +returned by C in the progress. This is a costly operation and +is usually done automatically within C. + +This function is rarely useful, but when some event callback runs for a +very long time without entering the event loop, updating libev's idea of +the current time is a good idea. + +See also "The special problem of time updates" in the C section. + =item ev_loop (loop, int flags) Finally, this is it, the event handler. This function usually is called @@ -1136,10 +1148,9 @@ =head3 The special problem of SIGPIPE While not really specific to libev, it is easy to forget about SIGPIPE: -when reading from a pipe whose other end has been closed, your program -gets send a SIGPIPE, which, by default, aborts your program. For most -programs this is sensible behaviour, for daemons, this is usually -undesirable. +when writing to a pipe whose other end has been closed, your program gets +send a SIGPIPE, which, by default, aborts your program. For most programs +this is sensible behaviour, for daemons, this is usually undesirable. So when you encounter spurious, unexplained daemon exits, make sure you ignore SIGPIPE (and maybe make sure you log the exit status of your daemon @@ -1200,17 +1211,29 @@ detecting time jumps is hard, and some inaccuracies are unavoidable (the monotonic clock option helps a lot here). +The callback is guaranteed to be invoked only after its timeout has passed, +but if multiple timers become ready during the same loop iteration then +order of execution is undefined. + +=head3 The special problem of time updates + +Establishing the current time is a costly operation (it usually takes at +least two system calls): EV therefore updates its idea of the current +time only before and after C polls for new events, which causes +a growing difference between C and C when handling +lots of events. + The relative timeouts are calculated relative to the C time. This is usually the right thing as this timestamp refers to the time of the event triggering whatever timeout you are modifying/starting. If -you suspect event processing to be delayed and you I to base the timeout -on the current time, use something like this to adjust for this: +you suspect event processing to be delayed and you I to base the +timeout on the current time, use something like this to adjust for this: ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); -The callback is guaranteed to be invoked only after its timeout has passed, -but if multiple timers become ready during the same loop iteration then -order of execution is undefined. +If the event loop is suspended for a long time, one can also force an +update of the time returned by C by calling C. =head3 Watcher-Specific Functions and Data Members @@ -1572,6 +1595,13 @@ event-based approach to child reaping and thus use libev's support for that, so other libev users can use C watchers freely. +=head3 Stopping the Child Watcher + +Currently, the child watcher never gets stopped, even when the +child terminates, so normally one needs to stop the watcher in the +callback. Future versions of libev might stop the watcher automatically +when a child exit is detected. + =head3 Watcher-Specific Functions and Data Members =over 4 @@ -2666,7 +2696,7 @@ =item D Leandro Lucarella has written a D language binding (F) for libev, to -be found at L. +be found at L. =back