--- AnyEvent/README 2006/11/01 01:22:19 1.6 +++ AnyEvent/README 2007/11/06 16:42:05 1.11 @@ -86,8 +86,8 @@ undef $w; }); - TIMER WATCHERS - You can create a timer watcher by calling the "AnyEvent->timer" method + TIME WATCHERS + You can create a time watcher by calling the "AnyEvent->timer" method with the following mandatory arguments: "after" after how many seconds (fractions are supported) should the @@ -147,6 +147,53 @@ $result_ready->wait; + SIGNAL WATCHERS + You can listen for signals using a signal watcher, "signal" is the + signal *name* without any "SIG" prefix. Multiple signals events can be + clumped together into one callback invocation, and callback invocation + might or might not be asynchronous. + + These watchers might use %SIG, so programs overwriting those signals + directly will likely not work correctly. + + Example: exit on SIGINT + + my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); + + CHILD PROCESS WATCHERS + You can also listen for the status of a child process specified by the + "pid" argument (or any child if the pid argument is 0). The watcher will + trigger as often as status change for the child are received. This works + by installing a signal handler for "SIGCHLD". The callback will be + called with the pid and exit status (as returned by waitpid). + + Example: wait for pid 1333 + + my $w = AnyEvent->child (pid => 1333, cb => sub { warn "exit status $?" }); + +GLOBALS + $AnyEvent::MODEL + Contains "undef" until the first watcher is being created. Then it + contains the event model that is being used, which is the name of + the Perl class implementing the model. This class is usually one of + the "AnyEvent::Impl:xxx" modules, but can be any other class in the + case AnyEvent has been extended at runtime (e.g. in *rxvt-unicode*). + + The known classes so far are: + + EV::AnyEvent based on EV (an interface to libev, best choice) + AnyEvent::Impl::Coro based on Coro::Event, second best choice. + AnyEvent::Impl::Event based on Event, also second best choice :) + AnyEvent::Impl::Glib based on Glib, second-best choice. + AnyEvent::Impl::Tk based on Tk, very bad choice. + AnyEvent::Impl::Perl pure-perl implementation, inefficient. + + AnyEvent::detect + Returns $AnyEvent::MODEL, forcing autodetection of the event model + if necessary. You should only call this function right before you + would have created an AnyEvent watcher anyway, that is, very late at + runtime. + WHAT TO DO IN A MODULE As a module author, you should "use AnyEvent" and call AnyEvent methods freely, but you should not load a specific event module or rely on it. @@ -193,7 +240,7 @@ AnyEvent is loaded and asked to find a suitable event model, it will first check for the presence of urxvt. - The class should prove implementations for all watcher types (see + The class should provide implementations for all watcher types (see AnyEvent::Impl::Event (source code), AnyEvent::Impl::Glib (Source code) and so on for actual examples, use "perldoc -m AnyEvent::Impl::Glib" to see the sources). @@ -207,7 +254,7 @@ *rxvt-unicode* also cheats a bit by not providing blocking access to condition variables: code blocking while waiting for a condition will "die". This still works with most modules/usages, and blocking calls - must not be in an interactive appliation, so it makes sense. + must not be in an interactive application, so it makes sense. ENVIRONMENT VARIABLES The following environment variables are used by this module: