--- AnyEvent/lib/AnyEvent.pm 2006/12/31 11:54:43 1.22 +++ AnyEvent/lib/AnyEvent.pm 2007/11/02 19:12:02 1.30 @@ -197,8 +197,9 @@ The known classes so far are: - AnyEvent::Impl::Coro based on Coro::Event, best choise. - AnyEvent::Impl::Event based on Event, also best choice :) + EV::AnyEvent based on EV (an interface to libev, best choice) + AnyEvent::Impl::Coro based on Coro::Event, second best choice. + AnyEvent::Impl::Event based on Event, also second best choice :) AnyEvent::Impl::Glib based on Glib, second-best choice. AnyEvent::Impl::Tk based on Tk, very bad choice. AnyEvent::Impl::Perl pure-perl implementation, inefficient. @@ -247,9 +248,10 @@ no warnings; use strict; + use Carp; -our $VERSION = '2.51'; +our $VERSION = '2.55'; our $MODEL; our $AUTOLOAD; @@ -261,6 +263,7 @@ my @models = ( [Coro::Event:: => AnyEvent::Impl::Coro::], + [EV:: => EV::AnyEvent::], [Event:: => AnyEvent::Impl::Event::], [Glib:: => AnyEvent::Impl::Glib::], [Tk:: => AnyEvent::Impl::Tk::], @@ -348,7 +351,7 @@ my $signal = uc $arg{signal} or Carp::croak "required option 'signal' is missing"; - $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; + $SIG_CB{$signal}{$arg{cb} += 0} = $arg{cb}; $SIG{$signal} ||= sub { $_->() for values %{ $SIG_CB{$signal} || {} }; }; @@ -373,7 +376,7 @@ sub _child_wait { while (0 < (my $pid = waitpid -1, $WNOHANG)) { - $_->() for values %{ (delete $PID_CB{$pid}) || {} }; + $_->() for values %{ $PID_CB{$pid} || {} }, %{ $PID_CB{0} || {} }; } undef $PID_IDLE; @@ -388,12 +391,14 @@ $PID_CB{$pid}{$arg{cb}} = $arg{cb}; unless ($WNOHANG) { - $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait); $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1; } - # child could be a zombie already - $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait); + unless ($CHLD_W) { + $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait); + # child could be a zombie already + $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait); + } bless [$pid, $arg{cb}], "AnyEvent::Base::Child" } @@ -439,7 +444,7 @@ I also cheats a bit by not providing blocking access to condition variables: code blocking while waiting for a condition will C. This still works with most modules/usages, and blocking calls must -not be in an interactive appliation, so it makes sense. +not be in an interactive application, so it makes sense. =head1 ENVIRONMENT VARIABLES