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.243 by root, Fri Jul 17 23:12:20 2009 UTC vs.
Revision 1.246 by root, Sat Jul 18 15:51:52 2009 UTC

1053 1053
1054BEGIN { AnyEvent::common_sense } 1054BEGIN { AnyEvent::common_sense }
1055 1055
1056use Carp (); 1056use Carp ();
1057 1057
1058our $VERSION = 4.83; 1058our $VERSION = 4.85;
1059our $MODEL; 1059our $MODEL;
1060 1060
1061our $AUTOLOAD; 1061our $AUTOLOAD;
1062our @ISA; 1062our @ISA;
1063 1063
1270 $_->() for values %{ $SIG_CB{$_} || {} }; 1270 $_->() for values %{ $SIG_CB{$_} || {} };
1271 } 1271 }
1272 } 1272 }
1273} 1273}
1274 1274
1275# install a dumym wakeupw atcher to reduce signal catching latency
1276sub _sig_add() {
1277 unless ($SIG_COUNT++) {
1278 # try to align timer on a full-second boundary, if possible
1279 my $NOW = AnyEvent->now;
1280
1281 $SIG_TW = AnyEvent->timer (
1282 after => $MAX_SIGNAL_LATENCY - ($NOW - int $NOW),
1283 interval => $MAX_SIGNAL_LATENCY,
1284 cb => sub { }, # just for the PERL_ASYNC_CHECK
1285 );
1286 }
1287}
1288
1289sub _sig_del {
1290 undef $SIG_TW
1291 unless --$SIG_COUNT;
1292}
1293
1275sub _signal { 1294sub _signal {
1276 my (undef, %arg) = @_; 1295 my (undef, %arg) = @_;
1277 1296
1278 my $signal = uc $arg{signal} 1297 my $signal = uc $arg{signal}
1279 or Carp::croak "required option 'signal' is missing"; 1298 or Carp::croak "required option 'signal' is missing";
1303 undef $SIG_EV{$signal}; 1322 undef $SIG_EV{$signal};
1304 }; 1323 };
1305 1324
1306 # can't do signal processing without introducing races in pure perl, 1325 # can't do signal processing without introducing races in pure perl,
1307 # so limit the signal latency. 1326 # so limit the signal latency.
1308 ++$SIG_COUNT; 1327 _sig_add;
1309 $SIG_TW ||= AnyEvent->timer (
1310 after => $MAX_SIGNAL_LATENCY,
1311 interval => $MAX_SIGNAL_LATENCY,
1312 cb => sub { }, # just for the PERL_ASYNC_CHECK
1313 );
1314 } 1328 }
1315 1329
1316 bless [$signal, $arg{cb}], "AnyEvent::Base::signal" 1330 bless [$signal, $arg{cb}], "AnyEvent::Base::signal"
1317} 1331}
1318 1332
1357} 1371}
1358 1372
1359sub AnyEvent::Base::signal::DESTROY { 1373sub AnyEvent::Base::signal::DESTROY {
1360 my ($signal, $cb) = @{$_[0]}; 1374 my ($signal, $cb) = @{$_[0]};
1361 1375
1362 undef $SIG_TW 1376 _sig_del;
1363 unless --$SIG_COUNT;
1364 1377
1365 delete $SIG_CB{$signal}{$cb}; 1378 delete $SIG_CB{$signal}{$cb};
1366 1379
1380 $HAVE_ASYNC_INTERRUPT
1381 ? delete $SIG_ASY{$signal}
1367 # delete doesn't work with older perls - they then 1382 : # delete doesn't work with older perls - they then
1368 # print weird messages, or just unconditionally exit 1383 # print weird messages, or just unconditionally exit
1369 # instead of getting the default action. 1384 # instead of getting the default action.
1370 undef $SIG{$signal} 1385 undef $SIG{$signal}
1371 unless keys %{ $SIG_CB{$signal} }; 1386 unless keys %{ $SIG_CB{$signal} };
1372} 1387}
1373 1388
1374# default implementation for ->child 1389# default implementation for ->child
1375 1390
1566C<PERL_ANYEVENT_MODEL>. 1581C<PERL_ANYEVENT_MODEL>.
1567 1582
1568When set to C<2> or higher, cause AnyEvent to report to STDERR which event 1583When set to C<2> or higher, cause AnyEvent to report to STDERR which event
1569model it chooses. 1584model it chooses.
1570 1585
1586When set to C<8> or higher, then AnyEvent will report extra information on
1587which optional modules it loads and how it implements certain features.
1588
1571=item C<PERL_ANYEVENT_STRICT> 1589=item C<PERL_ANYEVENT_STRICT>
1572 1590
1573AnyEvent does not do much argument checking by default, as thorough 1591AnyEvent does not do much argument checking by default, as thorough
1574argument checking is very costly. Setting this variable to a true value 1592argument checking is very costly. Setting this variable to a true value
1575will cause AnyEvent to load C<AnyEvent::Strict> and then to thoroughly 1593will cause AnyEvent to load C<AnyEvent::Strict> and then to thoroughly
1651 1669
1652When neither C<ca_file> nor C<ca_path> was specified during 1670When neither C<ca_file> nor C<ca_path> was specified during
1653L<AnyEvent::TLS> context creation, and either of these environment 1671L<AnyEvent::TLS> context creation, and either of these environment
1654variables exist, they will be used to specify CA certificate locations 1672variables exist, they will be used to specify CA certificate locations
1655instead of a system-dependent default. 1673instead of a system-dependent default.
1674
1675=item C<PERL_ANYEVENT_AVOID_GUARD> and C<PERL_ANYEVENT_AVOID_ASYNC_INTERRUPT>
1676
1677When these are set to C<1>, then the respective modules are not
1678loaded. Mostly good for testing AnyEvent itself.
1656 1679
1657=back 1680=back
1658 1681
1659=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE 1682=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE
1660 1683

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines