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.332 by root, Tue Aug 31 23:32:40 2010 UTC vs.
Revision 1.341 by root, Sun Dec 5 11:41:45 2010 UTC

46in a tutorial or some gentle introduction, have a look at the 46in a tutorial or some gentle introduction, have a look at the
47L<AnyEvent::Intro> manpage. 47L<AnyEvent::Intro> manpage.
48 48
49=head1 SUPPORT 49=head1 SUPPORT
50 50
51An FAQ document is available as L<AnyEvent::FAQ>.
52
51There is a mailinglist for discussing all things AnyEvent, and an IRC 53There also is a mailinglist for discussing all things AnyEvent, and an IRC
52channel, too. 54channel, too.
53 55
54See the AnyEvent project page at the B<Schmorpforge Ta-Sa Software 56See the AnyEvent project page at the B<Schmorpforge Ta-Sa Software
55Repository>, at L<http://anyevent.schmorp.de>, for more info. 57Repository>, at L<http://anyevent.schmorp.de>, for more info.
56 58
1165 1167
1166BEGIN { AnyEvent::common_sense } 1168BEGIN { AnyEvent::common_sense }
1167 1169
1168use Carp (); 1170use Carp ();
1169 1171
1170our $VERSION = '5.271'; 1172our $VERSION = '5.29';
1171our $MODEL; 1173our $MODEL;
1172 1174
1173our $AUTOLOAD; 1175our $AUTOLOAD;
1174our @ISA; 1176our @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
1624our %PID_CB; 1630our %PID_CB;
1625our $CHLD_W; 1631our $CHLD_W;
1626our $CHLD_DELAY_W; 1632our $CHLD_DELAY_W;
1627our $WNOHANG;
1628 1633
1629# used by many Impl's 1634# used by many Impl's
1630sub _emit_childstatus($$) { 1635sub _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
1726package AnyEvent::CondVar; 1726package AnyEvent::CondVar;
1727 1727
1728our @ISA = AnyEvent::CondVar::Base::; 1728our @ISA = AnyEvent::CondVar::Base::;
1729
1730# only to be used for subclassing
1731sub new {
1732 my $class = shift;
1733 bless AnyEvent->condvar (@_), $class
1734}
1729 1735
1730package AnyEvent::CondVar::Base; 1736package 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 (@_) } },
2652pronounced). 2658pronounced).
2653 2659
2654 2660
2655=head1 SEE ALSO 2661=head1 SEE ALSO
2656 2662
2663Tutorial/Introduction: L<AnyEvent::Intro>.
2664
2665FAQ: L<AnyEvent::FAQ>.
2666
2657Utility functions: L<AnyEvent::Util>. 2667Utility functions: L<AnyEvent::Util>.
2658 2668
2659Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>, 2669Event modules: L<EV>, L<EV::Glib>, L<Glib::EV>, L<Event>, L<Glib::Event>,
2660L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>. 2670L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>, L<POE>.
2661 2671
2667Non-blocking file handles, sockets, TCP clients and 2677Non-blocking file handles, sockets, TCP clients and
2668servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>. 2678servers: L<AnyEvent::Handle>, L<AnyEvent::Socket>, L<AnyEvent::TLS>.
2669 2679
2670Asynchronous DNS: L<AnyEvent::DNS>. 2680Asynchronous DNS: L<AnyEvent::DNS>.
2671 2681
2672Coroutine support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, 2682Thread support: L<Coro>, L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>.
2673L<Coro::Event>,
2674 2683
2675Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::XMPP>, 2684Nontrivial usage examples: L<AnyEvent::GPSD>, L<AnyEvent::IRC>,
2676L<AnyEvent::HTTP>. 2685L<AnyEvent::HTTP>.
2677 2686
2678 2687
2679=head1 AUTHOR 2688=head1 AUTHOR
2680 2689

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines