--- AnyEvent/lib/AnyEvent.pm 2008/05/31 13:38:01 1.151 +++ AnyEvent/lib/AnyEvent.pm 2008/07/08 19:50:25 1.164 @@ -172,9 +172,9 @@ always use non-blocking calls when reading/writing from/to your file handles. -Example: +Example: wait for readability of STDIN, then read a line and disable the +watcher. - # wait for readability of STDIN, then read a line and disable the watcher my $w; $w = AnyEvent->io (fh => \*STDIN, poll => 'r', cb => sub { chomp (my $input = ); warn "read: $input\n"; @@ -194,13 +194,17 @@ presence is undefined and you cannot rely on them. Portable AnyEvent callbacks cannot use arguments passed to time watcher callbacks. -The timer callback will be invoked at most once: if you want a repeating -timer you have to create a new watcher (this is a limitation by both Tk -and Glib). +The callback will normally be invoked once only. If you specify another +parameter, C, as a positive number, then the callback will be +invoked regularly at that interval (in fractional seconds) after the first +invocation. + +The callback will be rescheduled before invoking the callback, but no +attempt is done to avoid timer drift in most backends, so the interval is +only approximate. -Example: +Example: fire an event after 7.7 seconds. - # fire an event after 7.7 seconds my $w = AnyEvent->timer (after => 7.7, cb => sub { warn "timeout\n"; }); @@ -208,19 +212,12 @@ # to cancel the timer: undef $w; -Example 2: +Example 2: fire an event after 0.5 seconds, then roughly every second. - # fire an event after 0.5 seconds, then roughly every second - my $w; - - my $cb = sub { - # cancel the old timer while creating a new one - $w = AnyEvent->timer (after => 1, cb => $cb); + my $w = AnyEvent->timer (after => 0.5, interval => 1, cb => sub { + warn "timeout\n"; }; - # start the "loop" by creating the first watcher - $w = AnyEvent->timer (after => 0.5, cb => $cb); - =head3 TIMING ISSUES There are two ways to handle timers: based on real time (relative, "fire @@ -740,20 +737,27 @@ Contains various utility functions that replace often-used but blocking functions such as C by event-/callback-based versions. -=item L - -Provide read and write buffers and manages watchers for reads and writes. - =item L Provides various utility functions for (internet protocol) sockets, addresses and name resolution. Also functions to create non-blocking tcp connections or tcp servers, with IPv6 and SRV record support and more. +=item L + +Provide read and write buffers, manages watchers for reads and writes, +supports raw and formatted I/O, I/O queued and fully transparent and +non-blocking SSL/TLS. + =item L Provides rich asynchronous DNS resolver capabilities. +=item L + +A simple-to-use HTTP library that is capable of making a lot of concurrent +HTTP requests. + =item L Provides a simple web application server framework. @@ -762,6 +766,30 @@ The fastest ping in the west. +=item L + +Executes L requests asynchronously in a proxy process. + +=item L + +Truly asynchronous I/O, should be in the toolbox of every event +programmer. AnyEvent::AIO transparently fuses L and AnyEvent +together. + +=item L + +Truly asynchronous Berkeley DB access. AnyEvent::BDB transparently fuses +L and AnyEvent together. + +=item L + +A non-blocking interface to gpsd, a daemon delivering GPS information. + +=item L + +A non-blocking interface to the Internet Go Server protocol (used by +L). + =item L AnyEvent based IRC client module family. @@ -783,17 +811,6 @@ Has special support for AnyEvent via L. -=item L, L - -Truly asynchronous I/O, should be in the toolbox of every event -programmer. AnyEvent::AIO transparently fuses IO::AIO and AnyEvent -together. - -=item L, L - -Truly asynchronous Berkeley DB access. AnyEvent::AIO transparently fuses -IO::AIO and AnyEvent together. - =item L The lambda approach to I/O - don't ask, look there. Can use AnyEvent. @@ -809,7 +826,7 @@ use Carp; -our $VERSION = 4.11; +our $VERSION = 4.2; our $MODEL; our $AUTOLOAD; @@ -981,7 +998,7 @@ delete $SIG_CB{$signal}{$cb}; - $SIG{$signal} = 'DEFAULT' unless keys %{ $SIG_CB{$signal} }; + delete $SIG{$signal} unless keys %{ $SIG_CB{$signal} }; } # default implementation for ->child @@ -1669,6 +1686,15 @@ probably even less useful to an attacker than PERL_ANYEVENT_MODEL). +=head1 BUGS + +Perl 5.8 has numerous memleaks that sometimes hit this module and are hard +to work around. If you suffer from memleaks, first upgrade to Perl 5.10 +and check wether the leaks still show up. (Perl 5.10.0 has other annoying +mamleaks, such as leaking on C and C but it is usually not as +pronounced). + + =head1 SEE ALSO Utility functions: L.