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.259 by root, Tue Jul 28 02:07:18 2009 UTC vs.
Revision 1.262 by root, Tue Jul 28 13:08:17 2009 UTC

1086 1086
1087BEGIN { AnyEvent::common_sense } 1087BEGIN { AnyEvent::common_sense }
1088 1088
1089use Carp (); 1089use Carp ();
1090 1090
1091our $VERSION = 4.88; 1091our $VERSION = 4.881;
1092our $MODEL; 1092our $MODEL;
1093 1093
1094our $AUTOLOAD; 1094our $AUTOLOAD;
1095our @ISA; 1095our @ISA;
1096 1096
1306 $_->() for values %{ $SIG_CB{$_} || {} }; 1306 $_->() for values %{ $SIG_CB{$_} || {} };
1307 } 1307 }
1308 } 1308 }
1309} 1309}
1310 1310
1311# install a dumym wakeupw atcher to reduce signal catching latency 1311# install a dummy wakeup watcher to reduce signal catching latency
1312sub _sig_add() { 1312sub _sig_add() {
1313 unless ($SIG_COUNT++) { 1313 unless ($SIG_COUNT++) {
1314 # try to align timer on a full-second boundary, if possible 1314 # try to align timer on a full-second boundary, if possible
1315 my $NOW = AnyEvent->now; 1315 my $NOW = AnyEvent->now;
1316 1316
1331 my (undef, %arg) = @_; 1331 my (undef, %arg) = @_;
1332 1332
1333 my $signal = uc $arg{signal} 1333 my $signal = uc $arg{signal}
1334 or Carp::croak "required option 'signal' is missing"; 1334 or Carp::croak "required option 'signal' is missing";
1335 1335
1336 $SIG_CB{$signal}{$arg{cb}} = $arg{cb};
1337
1338 if ($HAVE_ASYNC_INTERRUPT) { 1336 if ($HAVE_ASYNC_INTERRUPT) {
1339 # async::interrupt 1337 # async::interrupt
1340 1338
1341 $SIG_ASY{$signal} ||= do { 1339 $signal = Async::Interrupt::sig2num ($signal);
1342 my $asy = new Async::Interrupt 1340 $SIG_CB{$signal}{$arg{cb}} = $arg{cb};
1341
1342 $SIG_ASY{$signal} ||= new Async::Interrupt
1343 cb => sub { undef $SIG_EV{$signal} }, 1343 cb => sub { undef $SIG_EV{$signal} },
1344 signal => $signal, 1344 signal => $signal,
1345 pipe => [$SIGPIPE_R->filenos], 1345 pipe => [$SIGPIPE_R->filenos],
1346 ;
1347 $asy->pipe_autodrain (0); 1346 pipe_autodrain => 0,
1348
1349 $asy
1350 }; 1347 ;
1351 1348
1352 } else { 1349 } else {
1353 # pure perl 1350 # pure perl
1351
1352 # AE::Util has been loaded in signal
1353 $signal = AnyEvent::Util::sig2name ($signal);
1354 $SIG_CB{$signal}{$arg{cb}} = $arg{cb};
1354 1355
1355 $SIG{$signal} ||= sub { 1356 $SIG{$signal} ||= sub {
1356 local $!; 1357 local $!;
1357 syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV; 1358 syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV;
1358 undef $SIG_EV{$signal}; 1359 undef $SIG_EV{$signal};
1366 bless [$signal, $arg{cb}], "AnyEvent::Base::signal" 1367 bless [$signal, $arg{cb}], "AnyEvent::Base::signal"
1367} 1368}
1368 1369
1369sub signal { 1370sub signal {
1370 # probe for availability of Async::Interrupt 1371 # probe for availability of Async::Interrupt
1371 if (!$ENV{PERL_ANYEVENT_AVOID_ASYNC_INTERRUPT} && eval "use Async::Interrupt 0.6 (); 1") { 1372 if (!$ENV{PERL_ANYEVENT_AVOID_ASYNC_INTERRUPT} && eval "use Async::Interrupt 1.0 (); 1") {
1372 warn "AnyEvent: using Async::Interrupt for race-free signal handling.\n" if $VERBOSE >= 8; 1373 warn "AnyEvent: using Async::Interrupt for race-free signal handling.\n" if $VERBOSE >= 8;
1373 1374
1374 $HAVE_ASYNC_INTERRUPT = 1; 1375 $HAVE_ASYNC_INTERRUPT = 1;
1375 $SIGPIPE_R = new Async::Interrupt::EventPipe; 1376 $SIGPIPE_R = new Async::Interrupt::EventPipe;
1376 $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R->fileno, poll => "r", cb => \&_signal_exec); 1377 $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R->fileno, poll => "r", cb => \&_signal_exec);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines