--- AnyEvent/lib/AnyEvent.pm 2011/10/04 17:45:04 1.390 +++ AnyEvent/lib/AnyEvent.pm 2013/03/01 06:03:21 1.410 @@ -435,7 +435,7 @@ means in some cases, signals will be delayed. The maximum time a signal might be delayed is 10 seconds by default, but can be overriden via C<$ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY}> or -C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the Ö +C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the L section for details. All these problems can be avoided by installing the optional @@ -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 "AnyEvent: IO::Async::Loop::AnyEvent detected - this module is broken by design,\n" - . "abuses internals and breaks AnyEvent, will not continue." + AnyEvent::log fatal => "IO::Async::Loop::AnyEvent detected - that module is broken by\n" + . "design, abuses internals and breaks AnyEvent - will not continue." if exists $INC{"IO/Async/Loop/AnyEvent.pm"}; local $!; # for good measure @@ -1418,10 +1427,10 @@ my $model = $1; $model = "AnyEvent::Impl::$model" unless $model =~ s/::$//; if (eval "require $model") { - AnyEvent::log 7 => "loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it."; + AnyEvent::log 7 => "Loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it."; $MODEL = $model; } else { - AnyEvent::log 4 => "unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@"; + AnyEvent::log 4 => "Unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@"; } } @@ -1431,9 +1440,11 @@ my ($package, $model) = @$_; if (${"$package\::VERSION"} > 0) { if (eval "require $model") { - AnyEvent::log 7 => "autodetected model '$model', using it."; + AnyEvent::log 7 => "Autodetected model '$model', using it."; $MODEL = $model; last; + } else { + AnyEvent::log 8 => "Detected event loop $package, but cannot load '$model', skipping: $@"; } } } @@ -1447,14 +1458,14 @@ and ${"$package\::VERSION"} > 0 and eval "require $model" ) { - AnyEvent::log 7 => "autoloaded model '$model', using it."; + AnyEvent::log 7 => "Autoloaded model '$model', using it."; $MODEL = $model; last; } } $MODEL - or AnyEvent::log fatal => "AnyEvent: backend autodetection failed - did you properly install AnyEvent?"; + or AnyEvent::log fatal => "Backend autodetection failed - did you properly install AnyEvent?"; } } @@ -1611,13 +1622,13 @@ *time = sub { Time::HiRes::time () }; *AE::time = \& Time::HiRes::time ; *now = \&time; - AnyEvent::log 8 => "AnyEvent: using Time::HiRes for sub-second timing accuracy."; + AnyEvent::log 8 => "using Time::HiRes for sub-second timing accuracy."; # if (eval "use POSIX (); (POSIX::times())... } else { *time = sub { CORE::time }; *AE::time = sub (){ CORE::time }; *now = \&time; - AnyEvent::log 3 => "using built-in time(), WARNING, no sub-second resolution!"; + AnyEvent::log 3 => "Using built-in time(), no sub-second resolution!"; } }; die if $@; @@ -1721,13 +1732,13 @@ eval q{ # poor man's autoloading {} # probe for availability of Async::Interrupt if (_have_async_interrupt) { - AnyEvent::log 8 => "using Async::Interrupt for race-free signal handling."; + AnyEvent::log 8 => "Using Async::Interrupt for race-free signal handling."; $SIGPIPE_R = new Async::Interrupt::EventPipe; $SIG_IO = AE::io $SIGPIPE_R->fileno, 0, \&_signal_exec; } else { - AnyEvent::log 8 => "using emulated perl signal handling with latency timer."; + AnyEvent::log 8 => "Using emulated perl signal handling with latency timer."; if (AnyEvent::WIN32) { require AnyEvent::Util; @@ -2073,28 +2084,28 @@ =item C -By default, AnyEvent will only log messages with loglevel C<3> -(C) or higher (see L). You can set this -environment variable to a numerical loglevel to make AnyEvent more (or -less) talkative. +By default, AnyEvent will log messages with loglevel C<4> (C) or +higher (see L). You can set this environment variable to a +numerical loglevel to make AnyEvent more (or less) talkative. If you want to do more than just set the global logging level you should have a look at C, which allows much more complex specifications. When set to C<0> (C), then no messages whatsoever will be logged with -the default logging settings. +everything else at defaults. -When set to C<5> or higher (C), causes AnyEvent to warn about -unexpected conditions, such as not being able to load the event model -specified by C, or a guard callback throwing an -exception - this is the minimum recommended level. +When set to C<5> or higher (C), AnyEvent warns about unexpected +conditions, such as not being able to load the event model specified by +C, or a guard callback throwing an exception - this +is the minimum recommended level for use during development. -When set to C<7> or higher (info), cause AnyEvent to report which event model it +When set to C<7> or higher (info), AnyEvent reports which event model it chooses. -When set to C<8> or higher (debug), then AnyEvent will report extra information on -which optional modules it loads and how it implements certain features. +When set to C<8> or higher (debug), then AnyEvent will report extra +information on which optional modules it loads and how it implements +certain features. =item C @@ -2111,8 +2122,8 @@ Note that specifying this environment variable causes the L module to be loaded, while C does not, so only -using the latter saves a few hundred kB of memory until the first message -is being logged. +using the latter saves a few hundred kB of memory unless a module +explicitly needs the extra features of AnyEvent::Log. =item C @@ -2177,6 +2188,14 @@ PERL_ANYEVENT_MODEL=Perl perl ... +=item C + +The current file I/O model - see L for more info. + +At the moment, only C (small, pure-perl, synchronous) and +C (truly asynchronous) are supported. The default is C if +L can be loaded, otherwise it is C. + =item C Used by both L and L to determine preferences @@ -2912,6 +2931,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 @@ -3004,6 +3033,8 @@ Non-blocking handles, pipes, stream sockets, TCP clients and servers: L, L, L. +Asynchronous File I/O: L. + Asynchronous DNS: L. Thread support: L, L, L, L. @@ -3015,7 +3046,7 @@ =head1 AUTHOR Marc Lehmann - http://home.schmorp.de/ + http://anyevent.schmorp.de =cut