--- AnyEvent/lib/AnyEvent.pm 2012/03/30 02:26:07 1.400 +++ AnyEvent/lib/AnyEvent.pm 2013/08/21 08:40:28 1.414 @@ -273,7 +273,7 @@ my $w = AnyEvent->timer (after => 0.5, interval => 1, cb => sub { warn "timeout\n"; - }; + }); =head3 TIMING ISSUES @@ -765,6 +765,10 @@ $cv->end; + ... + + my $results = $cv->recv; + This code fragment supposedly pings a number of hosts and calls C after results for all then have have been gathered - in any order. To achieve this, the code issues a call to C when it starts @@ -809,11 +813,15 @@ in scalar context only the first one will be returned. Note that doing a blocking wait in a callback is not supported by any -event loop, that is, recursive invocation of a blocking C<< ->recv ->> is not allowed, and the C call will C if such a -condition is detected. This condition can be slightly loosened by using -L, which allows you to do a blocking C<< ->recv >> from -any thread that doesn't run the event loop itself. +event loop, that is, recursive invocation of a blocking C<< ->recv >> is +not allowed and the C call will C if such a condition is +detected. This requirement can be dropped by relying on L +, which allows you to do a blocking C<< ->recv >> from any thread +that doesn't run the event loop itself. L is loaded +automatically when L is used with L, so code does not need +to do anything special to take advantage of that: any code that would +normally block your program because it calls C, be executed in an +C thread instead without blocking other threads. Not all event models support a blocking wait - some die in that case (programs might want to do that to stay interactive), so I +=item L (part of the AnyEvent distribution) Contains various utility functions that replace often-used blocking functions such as C with event/callback-based versions. -=item L +=item L (part of the AnyEvent distribution) 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 +=item L (part of the AnyEvent distribution) 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 (via L). -=item L +=item L (part of the AnyEvent distribution) Provides rich asynchronous DNS resolver capabilities. @@ -1168,7 +1176,7 @@ the curious, IGS is the International Go Server and FCP is the Freenet Client Protocol). -=item L +=item L (part of the AnyEvent distribution) Truly asynchronous (as opposed to non-blocking) I/O, should be in the toolbox of every event programmer. AnyEvent::AIO transparently fuses @@ -1223,20 +1231,14 @@ package AnyEvent; -# basically a tuned-down version of common::sense -sub common_sense { - # from common:.sense 3.5 - local $^W; - ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\x3c\x3f\x33\x00\x0f\xf0\x0f\xc0\xf0\xfc\x33\x00"; - # use strict vars subs - NO UTF-8, as Util.pm doesn't like this atm. (uts46data.pl) - $^H |= 0x00000600; +BEGIN { + require "AnyEvent/constants.pl"; + &AnyEvent::common_sense; } -BEGIN { AnyEvent::common_sense } - use Carp (); -our $VERSION = '6.14'; +our $VERSION = '7.05'; our $MODEL; our @ISA; our @REGISTRY; @@ -1245,8 +1247,6 @@ our $MAX_SIGNAL_LATENCY = $ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY} || 10; # executes after the BEGIN block below (tainting!) BEGIN { - require "AnyEvent/constants.pl"; - eval "sub TAINT (){" . (${^TAINT}*1) . "}"; delete @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} @@ -2923,6 +2923,16 @@ pure-perl event loop (L) will additionally load it to try to use a monotonic clock for timing stability. +=item L (and L) + +The default implementation of L is to do I/O synchronously, +stopping programs while they access the disk, which is fine for a lot of +programs. + +Installing AnyEvent::AIO (and its IO::AIO dependency) makes it switch to +a true asynchronous implementation, so event processing can continue even +while waiting for disk I/O. + =back @@ -3028,7 +3038,7 @@ =head1 AUTHOR Marc Lehmann - http://home.schmorp.de/ + http://anyevent.schmorp.de =cut