… | |
… | |
46 | in a tutorial or some gentle introduction, have a look at the |
46 | in a tutorial or some gentle introduction, have a look at the |
47 | L<AnyEvent::Intro> manpage. |
47 | L<AnyEvent::Intro> manpage. |
48 | |
48 | |
49 | =head1 SUPPORT |
49 | =head1 SUPPORT |
50 | |
50 | |
|
|
51 | An FAQ document is available as L<AnyEvent::FAQ>. |
|
|
52 | |
51 | There is a mailinglist for discussing all things AnyEvent, and an IRC |
53 | There also is a mailinglist for discussing all things AnyEvent, and an IRC |
52 | channel, too. |
54 | channel, too. |
53 | |
55 | |
54 | See the AnyEvent project page at the B<Schmorpforge Ta-Sa Software |
56 | See the AnyEvent project page at the B<Schmorpforge Ta-Sa Software |
55 | Repository>, at L<http://anyevent.schmorp.de>, for more info. |
57 | Repository>, at L<http://anyevent.schmorp.de>, for more info. |
56 | |
58 | |
… | |
… | |
1165 | |
1167 | |
1166 | BEGIN { AnyEvent::common_sense } |
1168 | BEGIN { AnyEvent::common_sense } |
1167 | |
1169 | |
1168 | use Carp (); |
1170 | use Carp (); |
1169 | |
1171 | |
1170 | our $VERSION = '5.271'; |
1172 | our $VERSION = '5.29'; |
1171 | our $MODEL; |
1173 | our $MODEL; |
1172 | |
1174 | |
1173 | our $AUTOLOAD; |
1175 | our $AUTOLOAD; |
1174 | our @ISA; |
1176 | our @ISA; |
1175 | |
1177 | |
… | |
… | |
1289 | last; |
1291 | last; |
1290 | } |
1292 | } |
1291 | } |
1293 | } |
1292 | |
1294 | |
1293 | $MODEL |
1295 | $MODEL |
1294 | or die "No event module selected for AnyEvent and autodetect failed. Install any one of these modules: EV, Event or Glib.\n"; |
1296 | or die "AnyEvent: backend autodetection failed - did you properly install AnyEvent?\n"; |
1295 | } |
1297 | } |
1296 | } |
1298 | } |
1297 | |
1299 | |
1298 | @models = (); # free probe data |
1300 | @models = (); # free probe data |
1299 | |
1301 | |
1300 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1302 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1301 | unshift @ISA, $MODEL; |
1303 | unshift @ISA, $MODEL; |
1302 | |
1304 | |
1303 | # now nuke some methods that are overriden by the backend. |
1305 | # now nuke some methods that are overridden by the backend. |
1304 | # SUPER is not allowed. |
1306 | # SUPER is not allowed. |
1305 | for (qw(time signal child idle)) { |
1307 | for (qw(time signal child idle)) { |
1306 | undef &{"AnyEvent::Base::$_"} |
1308 | undef &{"AnyEvent::Base::$_"} |
1307 | if defined &{"$MODEL\::$_"}; |
1309 | if defined &{"$MODEL\::$_"}; |
1308 | } |
1310 | } |
1309 | |
1311 | |
1310 | require AnyEvent::Strict if $ENV{PERL_ANYEVENT_STRICT}; |
1312 | if ($ENV{PERL_ANYEVENT_STRICT}) { |
|
|
1313 | eval { require AnyEvent::Strict }; |
|
|
1314 | warn "AnyEvent: cannot load AnyEvent::Strict: $@" |
|
|
1315 | if $@ && $VERBOSE; |
|
|
1316 | } |
1311 | |
1317 | |
1312 | (shift @post_detect)->() while @post_detect; |
1318 | (shift @post_detect)->() while @post_detect; |
1313 | |
1319 | |
1314 | *post_detect = sub(&) { |
1320 | *post_detect = sub(&) { |
1315 | shift->(); |
1321 | shift->(); |
… | |
… | |
1622 | # default implementation for ->child |
1628 | # default implementation for ->child |
1623 | |
1629 | |
1624 | our %PID_CB; |
1630 | our %PID_CB; |
1625 | our $CHLD_W; |
1631 | our $CHLD_W; |
1626 | our $CHLD_DELAY_W; |
1632 | our $CHLD_DELAY_W; |
1627 | our $WNOHANG; |
|
|
1628 | |
1633 | |
1629 | # used by many Impl's |
1634 | # used by many Impl's |
1630 | sub _emit_childstatus($$) { |
1635 | sub _emit_childstatus($$) { |
1631 | my (undef, $rpid, $rstatus) = @_; |
1636 | my (undef, $rpid, $rstatus) = @_; |
1632 | |
1637 | |
… | |
… | |
1639 | eval q{ # poor man's autoloading {} |
1644 | eval q{ # poor man's autoloading {} |
1640 | *_sigchld = sub { |
1645 | *_sigchld = sub { |
1641 | my $pid; |
1646 | my $pid; |
1642 | |
1647 | |
1643 | AnyEvent->_emit_childstatus ($pid, $?) |
1648 | AnyEvent->_emit_childstatus ($pid, $?) |
1644 | while ($pid = waitpid -1, $WNOHANG) > 0; |
1649 | while ($pid = waitpid -1, WNOHANG) > 0; |
1645 | }; |
1650 | }; |
1646 | |
1651 | |
1647 | *child = sub { |
1652 | *child = sub { |
1648 | my (undef, %arg) = @_; |
1653 | my (undef, %arg) = @_; |
1649 | |
1654 | |
1650 | defined (my $pid = $arg{pid} + 0) |
1655 | defined (my $pid = $arg{pid} + 0) |
1651 | or Carp::croak "required option 'pid' is missing"; |
1656 | or Carp::croak "required option 'pid' is missing"; |
1652 | |
1657 | |
1653 | $PID_CB{$pid}{$arg{cb}} = $arg{cb}; |
1658 | $PID_CB{$pid}{$arg{cb}} = $arg{cb}; |
1654 | |
|
|
1655 | # WNOHANG is almost cetrainly 1 everywhere |
|
|
1656 | $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/ |
|
|
1657 | ? 1 |
|
|
1658 | : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1; |
|
|
1659 | |
1659 | |
1660 | unless ($CHLD_W) { |
1660 | unless ($CHLD_W) { |
1661 | $CHLD_W = AE::signal CHLD => \&_sigchld; |
1661 | $CHLD_W = AE::signal CHLD => \&_sigchld; |
1662 | # child could be a zombie already, so make at least one round |
1662 | # child could be a zombie already, so make at least one round |
1663 | &_sigchld; |
1663 | &_sigchld; |
… | |
… | |
1724 | } |
1724 | } |
1725 | |
1725 | |
1726 | package AnyEvent::CondVar; |
1726 | package AnyEvent::CondVar; |
1727 | |
1727 | |
1728 | our @ISA = AnyEvent::CondVar::Base::; |
1728 | our @ISA = AnyEvent::CondVar::Base::; |
|
|
1729 | |
|
|
1730 | # only to be used for subclassing |
|
|
1731 | sub new { |
|
|
1732 | my $class = shift; |
|
|
1733 | bless AnyEvent->condvar (@_), $class |
|
|
1734 | } |
1729 | |
1735 | |
1730 | package AnyEvent::CondVar::Base; |
1736 | package AnyEvent::CondVar::Base; |
1731 | |
1737 | |
1732 | #use overload |
1738 | #use overload |
1733 | # '&{}' => sub { my $self = shift; sub { $self->send (@_) } }, |
1739 | # '&{}' => sub { my $self = shift; sub { $self->send (@_) } }, |
… | |
… | |
2652 | pronounced). |
2658 | pronounced). |
2653 | |
2659 | |
2654 | |
2660 | |
2655 | =head1 SEE ALSO |
2661 | =head1 SEE ALSO |
2656 | |
2662 | |
|
|
2663 | Tutorial/Introduction: L<AnyEvent::Intro>. |
|
|
2664 | |
|
|
2665 | FAQ: L<AnyEvent::FAQ>. |
|
|
2666 | |
2657 | Utility functions: L<AnyEvent::Util>. |
2667 | Utility functions: L<AnyEvent::Util>. |
2658 | |
2668 | |
2659 | Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>, |
2669 | Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>, |
2660 | L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. |
2670 | L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. |
2661 | |
2671 | |
… | |
… | |
2667 | Non-blocking file handles, sockets, TCP clients and |
2677 | Non-blocking file handles, sockets, TCP clients and |
2668 | servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>. |
2678 | servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>. |
2669 | |
2679 | |
2670 | Asynchronous DNS: L<AnyEvent::DNS>. |
2680 | Asynchronous DNS: L<AnyEvent::DNS>. |
2671 | |
2681 | |
2672 | Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, |
2682 | Thread support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>. |
2673 | L<Coro::Event>, |
|
|
2674 | |
2683 | |
2675 | Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::XMPP>, |
2684 | Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::IRC>, |
2676 | L<AnyEvent::HTTP>. |
2685 | L<AnyEvent::HTTP>. |
2677 | |
2686 | |
2678 | |
2687 | |
2679 | =head1 AUTHOR |
2688 | =head1 AUTHOR |
2680 | |
2689 | |