ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.388 by root, Sun Oct 2 01:22:01 2011 UTC vs.
Revision 1.396 by root, Sat Mar 10 17:36:24 2012 UTC

433as you cannot do race-free signal handling in perl, requiring 433as you cannot do race-free signal handling in perl, requiring
434C libraries for this. AnyEvent will try to do its best, which 434C libraries for this. AnyEvent will try to do its best, which
435means in some cases, signals will be delayed. The maximum time 435means in some cases, signals will be delayed. The maximum time
436a signal might be delayed is 10 seconds by default, but can 436a signal might be delayed is 10 seconds by default, but can
437be overriden via C<$ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY}> or 437be overriden via C<$ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY}> or
438C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the Ö<ENVIRONMENT VARIABLES> 438C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the L<ENVIRONMENT VARIABLES>
439section for details. 439section for details.
440 440
441All these problems can be avoided by installing the optional 441All these problems can be avoided by installing the optional
442L<Async::Interrupt> module, which works with most event loops. It will not 442L<Async::Interrupt> module, which works with most event loops. It will not
443work with inherently broken event loops such as L<Event> or L<Event::Lib> 443work with inherently broken event loops such as L<Event> or L<Event::Lib>
1233 1233
1234BEGIN { AnyEvent::common_sense } 1234BEGIN { AnyEvent::common_sense }
1235 1235
1236use Carp (); 1236use Carp ();
1237 1237
1238our $VERSION = '6.02'; 1238our $VERSION = '6.14';
1239our $MODEL; 1239our $MODEL;
1240our @ISA; 1240our @ISA;
1241our @REGISTRY; 1241our @REGISTRY;
1242our $VERBOSE; 1242our $VERBOSE;
1243our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred 1243our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred
1311 } 1311 }
1312 1312
1313 0 # not logged 1313 0 # not logged
1314} 1314}
1315 1315
1316sub logger($;$) { 1316sub _logger($;$) {
1317 package AnyEvent::Log;
1318
1319 my ($level, $renabled) = @_; 1317 my ($level, $renabled) = @_;
1320 1318
1321 $$renabled = $level <= $VERBOSE; 1319 $$renabled = $level <= $VERBOSE;
1322 1320
1323 my $pkg = (caller)[0];
1324
1325 my $logger = [$pkg, $level, $renabled]; 1321 my $logger = [(caller)[0], $level, $renabled];
1326 1322
1327 our %LOGGER;
1328 $LOGGER{$logger+0} = $logger; 1323 $AnyEvent::Log::LOGGER{$logger+0} = $logger;
1329 1324
1330 return unless defined wantarray; 1325# return unless defined wantarray;
1331 1326#
1332 require AnyEvent::Util; 1327# require AnyEvent::Util;
1333 my $guard = AnyEvent::Util::guard (sub { 1328# my $guard = AnyEvent::Util::guard (sub {
1334 # "clean up" 1329# # "clean up"
1335 delete $LOGGER{$logger+0}; 1330# delete $LOGGER{$logger+0};
1336 }); 1331# });
1337 1332#
1338 sub { 1333# sub {
1339 return 0 unless $$renabled; 1334# return 0 unless $$renabled;
1340 1335#
1341 $guard if 0; # keep guard alive, but don't cause runtime overhead 1336# $guard if 0; # keep guard alive, but don't cause runtime overhead
1342 require AnyEvent::Log unless $AnyEvent::Log::VERSION; 1337# require AnyEvent::Log unless $AnyEvent::Log::VERSION;
1343 package AnyEvent::Log; 1338# package AnyEvent::Log;
1344 _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time 1339# _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time
1345 } 1340# }
1346} 1341}
1347 1342
1348if (length $ENV{PERL_ANYEVENT_LOG}) { 1343if (length $ENV{PERL_ANYEVENT_LOG}) {
1349 require AnyEvent::Log; # AnyEvent::Log does the thing for us 1344 require AnyEvent::Log; # AnyEvent::Log does the thing for us
1350} 1345}
1400 1395
1401 # IO::Async::Loop::AnyEvent is extremely evil, refuse to work with it 1396 # IO::Async::Loop::AnyEvent is extremely evil, refuse to work with it
1402 # the author knows about the problems and what it does to AnyEvent as a whole 1397 # the author knows about the problems and what it does to AnyEvent as a whole
1403 # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent 1398 # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent
1404 # anyway. 1399 # anyway.
1405 AnyEvent::log fatal => "AnyEvent: IO::Async::Loop::AnyEvent detected - this module is broken by design,\n" 1400 AnyEvent::log fatal => "AnyEvent: IO::Async::Loop::AnyEvent detected - that module is broken by\n"
1406 . "abuses internals and breaks AnyEvent, will not continue." 1401 . "design, abuses internals and breaks AnyEvent - will not continue."
1407 if exists $INC{"IO/Async/Loop/AnyEvent.pm"}; 1402 if exists $INC{"IO/Async/Loop/AnyEvent.pm"};
1408 1403
1409 local $!; # for good measure 1404 local $!; # for good measure
1410 local $SIG{__DIE__}; # we use eval 1405 local $SIG{__DIE__}; # we use eval
1411 1406
1437 if (${"$package\::VERSION"} > 0) { 1432 if (${"$package\::VERSION"} > 0) {
1438 if (eval "require $model") { 1433 if (eval "require $model") {
1439 AnyEvent::log 7 => "autodetected model '$model', using it."; 1434 AnyEvent::log 7 => "autodetected model '$model', using it.";
1440 $MODEL = $model; 1435 $MODEL = $model;
1441 last; 1436 last;
1437 } else {
1438 AnyEvent::log 8 => "detected event loop $package, but cannot load '$model', skipping: $@";
1442 } 1439 }
1443 } 1440 }
1444 } 1441 }
1445 1442
1446 unless ($MODEL) { 1443 unless ($MODEL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines