|
NAMEAE - simpler/faster/newer/cooler AnyEvent APISYNOPSISuse AnyEvent; # not AE # file handle or descriptor readable my $w = AE::io $fh, 0, sub { ... }; # one-shot or repeating timers my $w = AE::timer $seconds, 0, sub { ... }; # once my $w = AE::timer $seconds, $interval, sub { ... }; # repeated print AE::now; # prints current event loop time print AE::time; # think Time::HiRes::time or simply CORE::time. # POSIX signal my $w = AE::signal TERM => sub { ... }; # child process exit my $w = AE::child $pid, sub { my ($pid, $status) = @_; ... }; # called when event loop idle (if applicable) my $w = AE::idle sub { ... }; my $cv = AE::cv; # stores whether a condition was flagged $cv->send; # wake up current and all future recv's $cv->recv; # enters "main loop" till $condvar gets ->send # use a condvar in callback mode: $cv->cb (sub { $_[0]->recv }); DESCRIPTIONThis module documents the new simpler AnyEvent API.The rationale for the new API is that experience with EV shows that this API actually "works", despite its lack of extensibility, leading to a shorter, easier and faster API. The main differences from AnyEvent is that function calls are used instead of method calls, and that no named arguments are used. This makes calls to watcher creation functions really short, which can make a program more readable despite the lack of named parameters. Function calls also allow more static type checking than method calls, so many mistakes are caught at compile-time with this API. Also, some backends (Perl and EV) are so fast that the method call overhead is very noticeable (with EV it increases the execution time five- to six-fold, with Perl the method call overhead is about a factor of two). Note that the "AE" API is an alternative to, not the future version of, the AnyEvent API. Both APIs can be used interchangeably and there are no plans to "switch", so if in doubt, feel free to use the AnyEvent API in new code. As the AE API is complementary, not everything in the AnyEvent API is available, and you still need to use AnyEvent for the finer stuff. Also, you should not "use AE" directly, "use AnyEvent" will provide the AE namespace. At the moment, these functions will become slower then their method-call counterparts when using AnyEvent::Strict or AnyEvent::Debug::wrap. FUNCTIONSThis section briefly describes the alternative watcher constructors and other functions available inside the "AE" namespace. Semantics are not described here; please refer to the description of the function or method with the same name in the AnyEvent manpage for the details.
AUTHORMarc Lehmann <schmorp@schmorp.de> http://anyevent.schmorp.de
Visit the GSP FreeBSD Man Page Interface. |