--- AnyEvent/lib/AE.pm 2009/12/05 02:58:30 1.4 +++ AnyEvent/lib/AE.pm 2010/03/24 23:28:06 1.7 @@ -6,6 +6,35 @@ use 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 { ... }; + + my $w = AE::cv; # stores whether a condition was flagged + $w->send; # wake up current and all future recv's + $w->recv; # enters "main loop" till $condvar gets ->send + # use a condvar in callback mode: + $w->cb (sub { $_[0]->recv }); + + =head1 DESCRIPTION This module documents the new simpler AnyEvent API. @@ -23,8 +52,8 @@ many mistakes are caught at compiletime with this API. Also, some backends (Perl and EV) are so fast that the method call -overhead is very noticable (with EV it increases the time five- to -six-fold, with Perl the method call overhead is about a factor of two). +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). At the moment, there will be no checking (L does not affect his API), so the L API has a definite advantage here @@ -32,7 +61,8 @@ Note that the C API is an alternative to, not the future version of, the AnyEvent API. Both APIs can be used interchangably and and there are -no plans to "switch", so if in doubt, use the L API. +no plans to "switch", so if in doubt, feel free to use the L +API in new code. As the AE API is complementary, not everything in the AnyEvent API is available, so you still need to use AnyEvent for the finer stuff. Also,