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.398 by root, Tue Mar 27 16:21:11 2012 UTC vs.
Revision 1.399 by root, Tue Mar 27 23:47:57 2012 UTC

1396 1396
1397 # IO::Async::Loop::AnyEvent is extremely evil, refuse to work with it 1397 # IO::Async::Loop::AnyEvent is extremely evil, refuse to work with it
1398 # the author knows about the problems and what it does to AnyEvent as a whole 1398 # the author knows about the problems and what it does to AnyEvent as a whole
1399 # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent 1399 # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent
1400 # anyway. 1400 # anyway.
1401 AnyEvent::log fatal => "AnyEvent: IO::Async::Loop::AnyEvent detected - that module is broken by\n" 1401 AnyEvent::log fatal => "IO::Async::Loop::AnyEvent detected - that module is broken by\n"
1402 . "design, abuses internals and breaks AnyEvent - will not continue." 1402 . "design, abuses internals and breaks AnyEvent - will not continue."
1403 if exists $INC{"IO/Async/Loop/AnyEvent.pm"}; 1403 if exists $INC{"IO/Async/Loop/AnyEvent.pm"};
1404 1404
1405 local $!; # for good measure 1405 local $!; # for good measure
1406 local $SIG{__DIE__}; # we use eval 1406 local $SIG{__DIE__}; # we use eval
1417 1417
1418 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z0-9:]+)$/) { 1418 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z0-9:]+)$/) {
1419 my $model = $1; 1419 my $model = $1;
1420 $model = "AnyEvent::Impl::$model" unless $model =~ s/::$//; 1420 $model = "AnyEvent::Impl::$model" unless $model =~ s/::$//;
1421 if (eval "require $model") { 1421 if (eval "require $model") {
1422 AnyEvent::log 7 => "loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it."; 1422 AnyEvent::log 7 => "Loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it.";
1423 $MODEL = $model; 1423 $MODEL = $model;
1424 } else { 1424 } else {
1425 AnyEvent::log 4 => "unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@"; 1425 AnyEvent::log 4 => "Unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@";
1426 } 1426 }
1427 } 1427 }
1428 1428
1429 # check for already loaded models 1429 # check for already loaded models
1430 unless ($MODEL) { 1430 unless ($MODEL) {
1431 for (@REGISTRY, @models) { 1431 for (@REGISTRY, @models) {
1432 my ($package, $model) = @$_; 1432 my ($package, $model) = @$_;
1433 if (${"$package\::VERSION"} > 0) { 1433 if (${"$package\::VERSION"} > 0) {
1434 if (eval "require $model") { 1434 if (eval "require $model") {
1435 AnyEvent::log 7 => "autodetected model '$model', using it."; 1435 AnyEvent::log 7 => "Autodetected model '$model', using it.";
1436 $MODEL = $model; 1436 $MODEL = $model;
1437 last; 1437 last;
1438 } else { 1438 } else {
1439 AnyEvent::log 8 => "detected event loop $package, but cannot load '$model', skipping: $@"; 1439 AnyEvent::log 8 => "Detected event loop $package, but cannot load '$model', skipping: $@";
1440 } 1440 }
1441 } 1441 }
1442 } 1442 }
1443 1443
1444 unless ($MODEL) { 1444 unless ($MODEL) {
1448 if ( 1448 if (
1449 eval "require $package" 1449 eval "require $package"
1450 and ${"$package\::VERSION"} > 0 1450 and ${"$package\::VERSION"} > 0
1451 and eval "require $model" 1451 and eval "require $model"
1452 ) { 1452 ) {
1453 AnyEvent::log 7 => "autoloaded model '$model', using it."; 1453 AnyEvent::log 7 => "Autoloaded model '$model', using it.";
1454 $MODEL = $model; 1454 $MODEL = $model;
1455 last; 1455 last;
1456 } 1456 }
1457 } 1457 }
1458 1458
1459 $MODEL 1459 $MODEL
1460 or AnyEvent::log fatal => "AnyEvent: backend autodetection failed - did you properly install AnyEvent?"; 1460 or AnyEvent::log fatal => "Backend autodetection failed - did you properly install AnyEvent?";
1461 } 1461 }
1462 } 1462 }
1463 1463
1464 # free memory only needed for probing 1464 # free memory only needed for probing
1465 undef @models; 1465 undef @models;
1612 # probe for availability of Time::HiRes 1612 # probe for availability of Time::HiRes
1613 if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { 1613 if (eval "use Time::HiRes (); Time::HiRes::time (); 1") {
1614 *time = sub { Time::HiRes::time () }; 1614 *time = sub { Time::HiRes::time () };
1615 *AE::time = \& Time::HiRes::time ; 1615 *AE::time = \& Time::HiRes::time ;
1616 *now = \&time; 1616 *now = \&time;
1617 AnyEvent::log 8 => "AnyEvent: using Time::HiRes for sub-second timing accuracy."; 1617 AnyEvent::log 8 => "using Time::HiRes for sub-second timing accuracy.";
1618 # if (eval "use POSIX (); (POSIX::times())... 1618 # if (eval "use POSIX (); (POSIX::times())...
1619 } else { 1619 } else {
1620 *time = sub { CORE::time }; 1620 *time = sub { CORE::time };
1621 *AE::time = sub (){ CORE::time }; 1621 *AE::time = sub (){ CORE::time };
1622 *now = \&time; 1622 *now = \&time;
1623 AnyEvent::log 3 => "using built-in time(), WARNING, no sub-second resolution!"; 1623 AnyEvent::log 3 => "Using built-in time(), no sub-second resolution!";
1624 } 1624 }
1625 }; 1625 };
1626 die if $@; 1626 die if $@;
1627 1627
1628 &time 1628 &time
1722 1722
1723sub signal { 1723sub signal {
1724 eval q{ # poor man's autoloading {} 1724 eval q{ # poor man's autoloading {}
1725 # probe for availability of Async::Interrupt 1725 # probe for availability of Async::Interrupt
1726 if (_have_async_interrupt) { 1726 if (_have_async_interrupt) {
1727 AnyEvent::log 8 => "using Async::Interrupt for race-free signal handling."; 1727 AnyEvent::log 8 => "Using Async::Interrupt for race-free signal handling.";
1728 1728
1729 $SIGPIPE_R = new Async::Interrupt::EventPipe; 1729 $SIGPIPE_R = new Async::Interrupt::EventPipe;
1730 $SIG_IO = AE::io $SIGPIPE_R->fileno, 0, \&_signal_exec; 1730 $SIG_IO = AE::io $SIGPIPE_R->fileno, 0, \&_signal_exec;
1731 1731
1732 } else { 1732 } else {
1733 AnyEvent::log 8 => "using emulated perl signal handling with latency timer."; 1733 AnyEvent::log 8 => "Using emulated perl signal handling with latency timer.";
1734 1734
1735 if (AnyEvent::WIN32) { 1735 if (AnyEvent::WIN32) {
1736 require AnyEvent::Util; 1736 require AnyEvent::Util;
1737 1737
1738 ($SIGPIPE_R, $SIGPIPE_W) = AnyEvent::Util::portable_pipe (); 1738 ($SIGPIPE_R, $SIGPIPE_W) = AnyEvent::Util::portable_pipe ();
3005L<AnyEvent::Impl::FLTK>. 3005L<AnyEvent::Impl::FLTK>.
3006 3006
3007Non-blocking handles, pipes, stream sockets, TCP clients and 3007Non-blocking handles, pipes, stream sockets, TCP clients and
3008servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>. 3008servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>.
3009 3009
3010Asynchronous File I/O: L<AnyEvent::IO>.
3011
3010Asynchronous DNS: L<AnyEvent::DNS>. 3012Asynchronous DNS: L<AnyEvent::DNS>.
3011 3013
3012Thread support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>. 3014Thread support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>.
3013 3015
3014Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::IRC>, 3016Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::IRC>,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines