--- cvsroot/EV/README 2008/01/28 12:24:05 1.22 +++ cvsroot/EV/README 2008/05/26 05:37:18 1.27 @@ -56,10 +56,17 @@ This module provides an interface to libev (). While the documentation below is comprehensive, one might also consult the documentation of - libev itself () for more subtle - details on watcher semantics or some discussion on the available - backends, or how to force a specific backend with "LIBEV_FLAGS", or just - about in any case because it has much more detailed information. + libev itself () + for more subtle details on watcher semantics or some discussion on the + available backends, or how to force a specific backend with + "LIBEV_FLAGS", or just about in any case because it has much more + detailed information. + + This module is very fast and scalable. It is actually so fast that you + can use it through the AnyEvent module, stay portable to other event + loops (if you don't rely on any watcher types not available through it) + and still be faster than with any other event loop currently supported + in Perl. EVENT LOOPS EV supports multiple event loops: There is a single "default event loop" @@ -91,11 +98,19 @@ $loop->loop_fork Must be called after a fork in the child, before entering or continuing the event loop. An alternative is to use - "EV::FLAG_FORKCHECK" which calls this fucntion automatically, at + "EV::FLAG_FORKCHECK" which calls this function automatically, at some performance loss (refer to the libev documentation). + $loop->loop_verify + Calls "ev_verify" to make internal consistency checks (for debugging + libev) and abort the program if any data structures wree found to be + corrupted. + $loop = EV::default_loop [$flags] - Return the default loop (which is a singleton object). + Return the default loop (which is a singleton object). Since this + module already creates the default loop with default flags, + specifying flags here will not have any effect unless you destroy + the default loop. BASIC INTERFACE $EV::DIED @@ -423,7 +438,7 @@ it is to be run at January 1st 2011 then it will run when the system time reaches or surpasses this time. - * non-repeating interval timer ($interval > 0, $reschedule_cb = 0) + * repeating interval timer ($interval > 0, $reschedule_cb = 0) In this mode the watcher will always be scheduled to time out at the next "$at + N * $interval" time (for some integer N) and @@ -451,14 +466,16 @@ first, and the current time as second argument. *This callback MUST NOT stop or destroy this or any other - periodic watcher, ever*. If you need to stop it, return 1e30 and - stop it afterwards. + periodic watcher, ever, and MUST NOT call any event loop + functions or methods*. If you need to stop it, return 1e30 and + stop it afterwards. You may create and start a "EV::prepare" + watcher for this task. It must return the next time to trigger, based on the passed - time value (that is, the lowest time value larger than to the - second argument). It will usually be called just before the - callback will be triggered, but might be called at other times, - too. + time value (that is, the lowest time value larger than or equal + to to the second argument). It will usually be called just + before the callback will be triggered, but might be called at + other times, too. This can be used to create very complex timers, such as a timer that triggers on each midnight, local time (actually 24 hours @@ -778,6 +795,20 @@ The "embed_ns" variant doesn't start (activate) the newly created watcher. + ASYNC WATCHERS - how to wake up another event loop + Async watchers are provided by EV, but have little use in perl directly, + as perl neither supports threads nor direct access to signal handlers or + other contexts where they could be of value. + + It is, however, possible to use them from the XS level. + + Please see the libev documentation for further details. + + $w = EV::async $callback + $w = EV::async_ns $callback + $w->send + $bool = $w->async_pending + PERL SIGNALS While Perl signal handling (%SIG) is not affected by EV, the behaviour with EV is as the same as any other C library: Perl-signals will only be @@ -821,7 +852,8 @@ SEE ALSO EV::ADNS (asynchronous DNS), Glib::EV (makes Glib/Gtk2 use EV as event loop), EV::Glib (embed Glib into EV), Coro::EV (efficient coroutines - with EV), Net::SNMP::EV (asynchronous SNMP). + with EV), Net::SNMP::EV (asynchronous SNMP), AnyEvent for event-loop + agnostic and portable event driven programming. AUTHOR Marc Lehmann