--- AnyEvent/lib/AnyEvent.pm 2009/07/29 13:10:58 1.265 +++ AnyEvent/lib/AnyEvent.pm 2009/07/30 03:41:56 1.266 @@ -183,6 +183,12 @@ =head2 I/O WATCHERS + $w = AnyEvent->io ( + fh => , + poll => <"r" or "w">, + cb => , + ); + You can create an I/O watcher by calling the C<< AnyEvent->io >> method with the following mandatory key-value pairs as arguments: @@ -221,6 +227,14 @@ =head2 TIME WATCHERS + $w = AnyEvent->timer (after => , cb => ); + + $w = AnyEvent->timer ( + after => , + interval => , + cb => , + ); + You can create a time watcher by calling the C<< AnyEvent->timer >> method with the following mandatory arguments: @@ -357,6 +371,8 @@ =head2 SIGNAL WATCHERS + $w = AnyEvent->signal (signal => , cb => ); + You can watch for signals using a signal watcher, C is the signal I in uppercase and without any C prefix, C is the Perl callback to be invoked whenever a signal occurs. @@ -400,6 +416,8 @@ =head2 CHILD PROCESS WATCHERS + $w = AnyEvent->child (pid => , cb => ); + You can also watch on a child process exit and catch its exit status. The child process is specified by the C argument (one some backends, @@ -457,6 +475,8 @@ =head2 IDLE WATCHERS + $w = AnyEvent->idle (cb => ); + Sometimes there is a need to do something, but it is not so important to do it instantly, but only when there is nothing better to do. This "nothing better to do" is usually defined to be "no other events need @@ -492,6 +512,11 @@ =head2 CONDITION VARIABLES + $cv = AnyEvent->condvar; + + $cv->send (); + my @res = $cv->recv; + If you are familiar with some event loops you will know that all of them require you to run some blocking "loop", "run" or similar function that will actively watch for new events and call your callbacks. @@ -1625,6 +1650,48 @@ *broadcast = \&send; *wait = \&_wait; +############################################################################# +# "new" API, currently only emulation of it +############################################################################# + +package AE; + +sub io($$$) { + AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) +} + +sub timer($$$) { + AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2]); +} + +sub signal($$) { + AnyEvent->signal (signal => $_[0], cb => $_[1]); +} + +sub child($$) { + AnyEvent->child (pid => $_[0], cb => $_[1]); +} + +sub idle($) { + AnyEvent->idle (cb => $_[0]); +} + +sub cv() { + AnyEvent->condvar +} + +sub now() { + AnyEvent->now +} + +sub now_update() { + AnyEvent->now_update +} + +sub time() { + AnyEvent->time +} + =head1 ERROR AND EXCEPTION HANDLING In general, AnyEvent does not do any error handling - it relies on the