… | |
… | |
876 | AnyEvent::Impl::Glib based on Glib, slow but very stable. |
876 | AnyEvent::Impl::Glib based on Glib, slow but very stable. |
877 | AnyEvent::Impl::Tk based on Tk, very broken. |
877 | AnyEvent::Impl::Tk based on Tk, very broken. |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
|
|
881 | AnyEvent::Impl::IOAsync based on IO::Async. |
881 | |
882 | |
882 | =item Backends with special needs. |
883 | =item Backends with special needs. |
883 | |
884 | |
884 | Qt requires the Qt::Application to be instantiated first, but will |
885 | Qt requires the Qt::Application to be instantiated first, but will |
885 | otherwise be picked up automatically. As long as the main program |
886 | otherwise be picked up automatically. As long as the main program |
886 | instantiates the application before any AnyEvent watchers are created, |
887 | instantiates the application before any AnyEvent watchers are created, |
887 | everything should just work. |
888 | everything should just work. |
888 | |
889 | |
889 | AnyEvent::Impl::Qt based on Qt. |
890 | AnyEvent::Impl::Qt based on Qt. |
890 | |
|
|
891 | Support for IO::Async can only be partial, as it is too broken and |
|
|
892 | architecturally limited to even support the AnyEvent API. It also |
|
|
893 | is the only event loop that needs the loop to be set explicitly, so |
|
|
894 | it can only be used by a main program knowing about AnyEvent. See |
|
|
895 | L<AnyEvent::Impl::IOAsync> for the gory details. |
|
|
896 | |
|
|
897 | AnyEvent::Impl::IOAsync based on IO::Async, cannot be autoprobed. |
|
|
898 | |
891 | |
899 | =item Event loops that are indirectly supported via other backends. |
892 | =item Event loops that are indirectly supported via other backends. |
900 | |
893 | |
901 | Some event loops can be supported via other modules: |
894 | Some event loops can be supported via other modules: |
902 | |
895 | |
… | |
… | |
1215 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
1208 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
1216 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
1209 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
1217 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1210 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1218 | [Wx:: => AnyEvent::Impl::POE::], |
1211 | [Wx:: => AnyEvent::Impl::POE::], |
1219 | [Prima:: => AnyEvent::Impl::POE::], |
1212 | [Prima:: => AnyEvent::Impl::POE::], |
1220 | # IO::Async is just too broken - we would need workarounds for its |
|
|
1221 | # byzantine signal and broken child handling, among others. |
|
|
1222 | # IO::Async is rather hard to detect, as it doesn't have any |
|
|
1223 | # obvious default class. |
|
|
1224 | [IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program |
|
|
1225 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1213 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], |
1226 | [IO::Async::Notifier:: => AnyEvent::Impl::IOAsync::], # requires special main program |
|
|
1227 | [AnyEvent::Impl::IOAsync:: => AnyEvent::Impl::IOAsync::], # requires special main program |
|
|
1228 | ); |
1214 | ); |
1229 | |
1215 | |
1230 | our %method = map +($_ => 1), |
1216 | our %method = map +($_ => 1), |
1231 | qw(io timer time now now_update signal child idle condvar one_event DESTROY); |
1217 | qw(io timer time now now_update signal child idle condvar one_event DESTROY); |
1232 | |
1218 | |
… | |
… | |
1628 | # default implementation for ->child |
1614 | # default implementation for ->child |
1629 | |
1615 | |
1630 | our %PID_CB; |
1616 | our %PID_CB; |
1631 | our $CHLD_W; |
1617 | our $CHLD_W; |
1632 | our $CHLD_DELAY_W; |
1618 | our $CHLD_DELAY_W; |
1633 | our $WNOHANG; |
|
|
1634 | |
1619 | |
1635 | # used by many Impl's |
1620 | # used by many Impl's |
1636 | sub _emit_childstatus($$) { |
1621 | sub _emit_childstatus($$) { |
1637 | my (undef, $rpid, $rstatus) = @_; |
1622 | my (undef, $rpid, $rstatus) = @_; |
1638 | |
1623 | |
… | |
… | |
1645 | eval q{ # poor man's autoloading {} |
1630 | eval q{ # poor man's autoloading {} |
1646 | *_sigchld = sub { |
1631 | *_sigchld = sub { |
1647 | my $pid; |
1632 | my $pid; |
1648 | |
1633 | |
1649 | AnyEvent->_emit_childstatus ($pid, $?) |
1634 | AnyEvent->_emit_childstatus ($pid, $?) |
1650 | while ($pid = waitpid -1, $WNOHANG) > 0; |
1635 | while ($pid = waitpid -1, WNOHANG) > 0; |
1651 | }; |
1636 | }; |
1652 | |
1637 | |
1653 | *child = sub { |
1638 | *child = sub { |
1654 | my (undef, %arg) = @_; |
1639 | my (undef, %arg) = @_; |
1655 | |
1640 | |
1656 | defined (my $pid = $arg{pid} + 0) |
1641 | defined (my $pid = $arg{pid} + 0) |
1657 | or Carp::croak "required option 'pid' is missing"; |
1642 | or Carp::croak "required option 'pid' is missing"; |
1658 | |
1643 | |
1659 | $PID_CB{$pid}{$arg{cb}} = $arg{cb}; |
1644 | $PID_CB{$pid}{$arg{cb}} = $arg{cb}; |
1660 | |
|
|
1661 | # WNOHANG is almost cetrainly 1 everywhere |
|
|
1662 | $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/ |
|
|
1663 | ? 1 |
|
|
1664 | : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1; |
|
|
1665 | |
1645 | |
1666 | unless ($CHLD_W) { |
1646 | unless ($CHLD_W) { |
1667 | $CHLD_W = AE::signal CHLD => \&_sigchld; |
1647 | $CHLD_W = AE::signal CHLD => \&_sigchld; |
1668 | # child could be a zombie already, so make at least one round |
1648 | # child could be a zombie already, so make at least one round |
1669 | &_sigchld; |
1649 | &_sigchld; |