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.335 by root, Wed Oct 13 01:17:02 2010 UTC vs.
Revision 1.341 by root, Sun Dec 5 11:41:45 2010 UTC

1167 1167
1168BEGIN { AnyEvent::common_sense } 1168BEGIN { AnyEvent::common_sense }
1169 1169
1170use Carp (); 1170use Carp ();
1171 1171
1172our $VERSION = '5.271'; 1172our $VERSION = '5.29';
1173our $MODEL; 1173our $MODEL;
1174 1174
1175our $AUTOLOAD; 1175our $AUTOLOAD;
1176our @ISA; 1176our @ISA;
1177 1177
1291 last; 1291 last;
1292 } 1292 }
1293 } 1293 }
1294 1294
1295 $MODEL 1295 $MODEL
1296 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";
1297 } 1297 }
1298 } 1298 }
1299 1299
1300 @models = (); # free probe data 1300 @models = (); # free probe data
1301 1301
1302 push @{"$MODEL\::ISA"}, "AnyEvent::Base"; 1302 push @{"$MODEL\::ISA"}, "AnyEvent::Base";
1303 unshift @ISA, $MODEL; 1303 unshift @ISA, $MODEL;
1304 1304
1305 # now nuke some methods that are overriden by the backend. 1305 # now nuke some methods that are overridden by the backend.
1306 # SUPER is not allowed. 1306 # SUPER is not allowed.
1307 for (qw(time signal child idle)) { 1307 for (qw(time signal child idle)) {
1308 undef &{"AnyEvent::Base::$_"} 1308 undef &{"AnyEvent::Base::$_"}
1309 if defined &{"$MODEL\::$_"}; 1309 if defined &{"$MODEL\::$_"};
1310 } 1310 }
1311 1311
1312 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 }
1313 1317
1314 (shift @post_detect)->() while @post_detect; 1318 (shift @post_detect)->() while @post_detect;
1315 1319
1316 *post_detect = sub(&) { 1320 *post_detect = sub(&) {
1317 shift->(); 1321 shift->();
1624# default implementation for ->child 1628# default implementation for ->child
1625 1629
1626our %PID_CB; 1630our %PID_CB;
1627our $CHLD_W; 1631our $CHLD_W;
1628our $CHLD_DELAY_W; 1632our $CHLD_DELAY_W;
1629our $WNOHANG;
1630 1633
1631# used by many Impl's 1634# used by many Impl's
1632sub _emit_childstatus($$) { 1635sub _emit_childstatus($$) {
1633 my (undef, $rpid, $rstatus) = @_; 1636 my (undef, $rpid, $rstatus) = @_;
1634 1637
1641 eval q{ # poor man's autoloading {} 1644 eval q{ # poor man's autoloading {}
1642 *_sigchld = sub { 1645 *_sigchld = sub {
1643 my $pid; 1646 my $pid;
1644 1647
1645 AnyEvent->_emit_childstatus ($pid, $?) 1648 AnyEvent->_emit_childstatus ($pid, $?)
1646 while ($pid = waitpid -1, $WNOHANG) > 0; 1649 while ($pid = waitpid -1, WNOHANG) > 0;
1647 }; 1650 };
1648 1651
1649 *child = sub { 1652 *child = sub {
1650 my (undef, %arg) = @_; 1653 my (undef, %arg) = @_;
1651 1654
1652 defined (my $pid = $arg{pid} + 0) 1655 defined (my $pid = $arg{pid} + 0)
1653 or Carp::croak "required option 'pid' is missing"; 1656 or Carp::croak "required option 'pid' is missing";
1654 1657
1655 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 1658 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
1656
1657 # WNOHANG is almost cetrainly 1 everywhere
1658 $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/
1659 ? 1
1660 : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1;
1661 1659
1662 unless ($CHLD_W) { 1660 unless ($CHLD_W) {
1663 $CHLD_W = AE::signal CHLD => \&_sigchld; 1661 $CHLD_W = AE::signal CHLD => \&_sigchld;
1664 # 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
1665 &_sigchld; 1663 &_sigchld;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines