--- AnyEvent/lib/AnyEvent.pm 2011/10/01 22:39:29 1.387 +++ AnyEvent/lib/AnyEvent.pm 2012/12/06 12:04:23 1.408 @@ -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 @@ -1225,7 +1229,8 @@ # basically a tuned-down version of common::sense sub common_sense { - # from common:.sense 3.4 + # 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; @@ -1235,7 +1240,7 @@ use Carp (); -our $VERSION = '6.02'; +our $VERSION = '7.04'; our $MODEL; our @ISA; our @REGISTRY; @@ -1304,6 +1309,7 @@ sub log($$;@) { # only load the big bloated module when we actually are about to log something if ($_[0] <= ($VERBOSE || 1)) { # also catches non-numeric levels(!) and fatal + local ($!, $@); require AnyEvent::Log; # among other things, sets $VERBOSE to 9 # AnyEvent::Log overwrites this function goto &log; @@ -1312,34 +1318,31 @@ 0 # not logged } -sub logger($;$) { - package AnyEvent::Log; - +sub _logger($;$) { my ($level, $renabled) = @_; $$renabled = $level <= $VERBOSE; - my $pkg = (caller)[0]; - - my $logger = [$pkg, $level, $renabled]; - - our %LOGGER; - $LOGGER{$logger+0} = $logger; - - require AnyEvent::Util; - my $guard = AnyEvent::Util::guard (sub { - # "clean up" - delete $LOGGER{$logger+0}; - }); + my $logger = [(caller)[0], $level, $renabled]; - sub { - return 0 unless $$renabled; + $AnyEvent::Log::LOGGER{$logger+0} = $logger; - $guard if 0; # keep guard alive, but don't cause runtime overhead - require AnyEvent::Log unless $AnyEvent::Log::VERSION; - package AnyEvent::Log; - _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time - } +# return unless defined wantarray; +# +# require AnyEvent::Util; +# my $guard = AnyEvent::Util::guard (sub { +# # "clean up" +# delete $LOGGER{$logger+0}; +# }); +# +# sub { +# return 0 unless $$renabled; +# +# $guard if 0; # keep guard alive, but don't cause runtime overhead +# require AnyEvent::Log unless $AnyEvent::Log::VERSION; +# package AnyEvent::Log; +# _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time +# } } if (length $ENV{PERL_ANYEVENT_LOG}) { @@ -1399,8 +1402,8 @@ # the author knows about the problems and what it does to AnyEvent as a whole # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent # anyway. - AnyEvent::log fatal => "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 @@ -1420,10 +1423,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$@"; } } @@ -1433,9 +1436,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: $@"; } } } @@ -1449,14 +1454,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?"; } } @@ -1613,13 +1618,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 $@; @@ -1723,13 +1728,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; @@ -2075,28 +2080,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 @@ -2113,8 +2118,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 @@ -2179,6 +2184,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 @@ -3006,6 +3019,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. @@ -3017,7 +3032,7 @@ =head1 AUTHOR Marc Lehmann - http://home.schmorp.de/ + http://anyevent.schmorp.de =cut