--- AnyEvent/lib/AnyEvent.pm 2010/12/03 18:38:32 1.339 +++ AnyEvent/lib/AnyEvent.pm 2011/08/02 20:02:44 1.350 @@ -87,12 +87,12 @@ AnyEvent is different: AnyEvent + POE works fine. AnyEvent + Glib works fine. AnyEvent + Tk works fine etc. etc. but none of these work together -with the rest: POE + IO::Async? No go. Tk + Event? No go. Again: if -your module uses one of those, every user of your module has to use it, -too. But if your module uses AnyEvent, it works transparently with all -event models it supports (including stuff like IO::Async, as long as those -use one of the supported event loops. It is easy to add new event loops -to AnyEvent, too, so it is future-proof). +with the rest: POE + EV? No go. Tk + Event? No go. Again: if your module +uses one of those, every user of your module has to use it, too. But if +your module uses AnyEvent, it works transparently with all event models it +supports (including stuff like IO::Async, as long as those use one of the +supported event loops. It is easy to add new event loops to AnyEvent, too, +so it is future-proof). In addition to being free of having to use I, AnyEvent also is free of bloat and policy: with POE or similar @@ -878,6 +878,9 @@ AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. AnyEvent::Impl::POE based on POE, very slow, some limitations. AnyEvent::Impl::Irssi used when running within irssi. + AnyEvent::Impl::IOAsync based on IO::Async. + AnyEvent::Impl::Cocoa based on Cocoa::EventLoop. + AnyEvent::Impl::FLTK based on FLTK. =item Backends with special needs. @@ -888,14 +891,6 @@ AnyEvent::Impl::Qt based on Qt. -Support for IO::Async can only be partial, as it is too broken and -architecturally limited to even support the AnyEvent API. It also -is the only event loop that needs the loop to be set explicitly, so -it can only be used by a main program knowing about AnyEvent. See -L for the gory details. - - AnyEvent::Impl::IOAsync based on IO::Async, cannot be autoprobed. - =item Event loops that are indirectly supported via other backends. Some event loops can be supported via other modules: @@ -1159,8 +1154,8 @@ # basically a tuned-down version of common::sense sub common_sense { - # from common:.sense 3.3 - ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\x3c\x3f\x33\x00\x0f\xf3\x0f\xc0\xf0\xfc\x33\x00"; + # from common:.sense 3.4 + ${^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; } @@ -1169,7 +1164,7 @@ use Carp (); -our $VERSION = '5.29'; +our $VERSION = '5.34'; our $MODEL; our $AUTOLOAD; @@ -1217,18 +1212,13 @@ [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza [Wx:: => AnyEvent::Impl::POE::], [Prima:: => AnyEvent::Impl::POE::], - # IO::Async is just too broken - we would need workarounds for its - # byzantine signal and broken child handling, among others. - # IO::Async is rather hard to detect, as it doesn't have any - # obvious default class. - [IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program - [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program - [IO::Async::Notifier:: => AnyEvent::Impl::IOAsync::], # requires special main program - [AnyEvent::Impl::IOAsync:: => AnyEvent::Impl::IOAsync::], # requires special main program + [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], + [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], + [FLTK:: => AnyEvent::Impl::FLTK::], ); our %method = map +($_ => 1), - qw(io timer time now now_update signal child idle condvar one_event DESTROY); + qw(io timer time now now_update signal child idle condvar DESTROY); our @post_detect; @@ -1311,7 +1301,7 @@ if ($ENV{PERL_ANYEVENT_STRICT}) { eval { require AnyEvent::Strict }; - warn "AnyEvent: cannot load AnyEvent::Strict ($@)\n" + warn "AnyEvent: cannot load AnyEvent::Strict: $@" if $@ && $VERBOSE; } @@ -1630,7 +1620,6 @@ our %PID_CB; our $CHLD_W; our $CHLD_DELAY_W; -our $WNOHANG; # used by many Impl's sub _emit_childstatus($$) { @@ -1647,7 +1636,7 @@ my $pid; AnyEvent->_emit_childstatus ($pid, $?) - while ($pid = waitpid -1, $WNOHANG) > 0; + while ($pid = waitpid -1, WNOHANG) > 0; }; *child = sub { @@ -1658,11 +1647,6 @@ $PID_CB{$pid}{$arg{cb}} = $arg{cb}; - # WNOHANG is almost cetrainly 1 everywhere - $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/ - ? 1 - : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1; - unless ($CHLD_W) { $CHLD_W = AE::signal CHLD => \&_sigchld; # child could be a zombie already, so make at least one round @@ -1757,6 +1741,10 @@ # nop } +sub _wait { + Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught"; +} + sub send { my $cv = shift; $cv->{_ae_sent} = [@_]; @@ -1773,20 +1761,21 @@ $_[0]{_ae_sent} } -sub _wait { - $WAITING - and !$_[0]{_ae_sent} - and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected"; +sub recv { + unless ($_[0]{_ae_sent}) { + $WAITING + and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected"; - local $WAITING = 1; - AnyEvent->one_event while !$_[0]{_ae_sent}; -} + local $WAITING = 1; + $_[0]->_wait; + } -sub recv { - $_[0]->_wait; + $_[0]{_ae_croak} + and Carp::croak $_[0]{_ae_croak}; - Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak}; - wantarray ? @{ $_[0]{_ae_sent} } : $_[0]{_ae_sent}[0] + wantarray + ? @{ $_[0]{_ae_sent} } + : $_[0]{_ae_sent}[0] } sub cb { @@ -1812,7 +1801,7 @@ # undocumented/compatibility with pre-3.4 *broadcast = \&send; -*wait = \&_wait; +*wait = \&recv; =head1 ERROR AND EXCEPTION HANDLING