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.241 by root, Fri Jul 17 18:08:35 2009 UTC vs.
Revision 1.245 by root, Sat Jul 18 05:19:09 2009 UTC

361invocation, and callback invocation will be synchronous. Synchronous means 361invocation, and callback invocation will be synchronous. Synchronous means
362that it might take a while until the signal gets handled by the process, 362that it might take a while until the signal gets handled by the process,
363but it is guaranteed not to interrupt any other callbacks. 363but it is guaranteed not to interrupt any other callbacks.
364 364
365The main advantage of using these watchers is that you can share a signal 365The main advantage of using these watchers is that you can share a signal
366between multiple watchers. 366between multiple watchers, and AnyEvent will ensure that signals will not
367interrupt your program at bad times.
367 368
368This watcher might use C<%SIG>, so programs overwriting those signals 369This watcher might use C<%SIG> (depending on the event loop used),
369directly will likely not work correctly. 370so programs overwriting those signals directly will likely not work
371correctly.
372
373Also note that many event loops (e.g. Glib, Tk, Qt, IO::Async) do not
374support attaching callbacks to signals, which is a pity, as you cannot do
375race-free signal handling in perl. AnyEvent will try to do it's best, but
376in some cases, signals will be delayed. The maximum time a signal might
377be delayed is specified in C<$AnyEvent::MAX_SIGNAL_LATENCY> (default: 10
378seconds). This variable can be changed only before the first signal
379watcher is created, and should be left alone otherwise. Higher values
380will cause fewer spurious wake-ups, which is better for power and CPU
381saving. All these problems can be avoided by installing the optional
382L<Async::Interrupt> module.
370 383
371Example: exit on SIGINT 384Example: exit on SIGINT
372 385
373 my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); 386 my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 });
374 387
403 416
404This means you cannot create a child watcher as the very first 417This means you cannot create a child watcher as the very first
405thing in an AnyEvent program, you I<have> to create at least one 418thing in an AnyEvent program, you I<have> to create at least one
406watcher before you C<fork> the child (alternatively, you can call 419watcher before you C<fork> the child (alternatively, you can call
407C<AnyEvent::detect>). 420C<AnyEvent::detect>).
421
422As most event loops do not support waiting for child events, they will be
423emulated by AnyEvent in most cases, in which the latency and race problems
424mentioned in the description of signal watchers apply.
408 425
409Example: fork a process and wait for it 426Example: fork a process and wait for it
410 427
411 my $done = AnyEvent->condvar; 428 my $done = AnyEvent->condvar;
412 429
1024 1041
1025=cut 1042=cut
1026 1043
1027package AnyEvent; 1044package AnyEvent;
1028 1045
1046# basically a tuned-down version of common::sense
1047sub common_sense {
1029no warnings; 1048 # no warnings
1049 ${^WARNING_BITS} ^= ${^WARNING_BITS};
1030use strict qw(vars subs); 1050 # use strict vars subs
1051 $^H |= 0x00000600;
1052}
1053
1054BEGIN { AnyEvent::common_sense }
1031 1055
1032use Carp (); 1056use Carp ();
1033 1057
1034our $VERSION = 4.83; 1058our $VERSION = 4.85;
1035our $MODEL; 1059our $MODEL;
1036 1060
1037our $AUTOLOAD; 1061our $AUTOLOAD;
1038our @ISA; 1062our @ISA;
1039 1063
1040our @REGISTRY; 1064our @REGISTRY;
1041 1065
1042our $WIN32; 1066our $WIN32;
1067
1068our $VERBOSE;
1043 1069
1044BEGIN { 1070BEGIN {
1045 eval "sub WIN32(){ " . (($^O =~ /mswin32/i)*1) ." }"; 1071 eval "sub WIN32(){ " . (($^O =~ /mswin32/i)*1) ." }";
1046 eval "sub TAINT(){ " . (${^TAINT}*1) . " }"; 1072 eval "sub TAINT(){ " . (${^TAINT}*1) . " }";
1047 1073
1048 delete @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} 1074 delete @ENV{grep /^PERL_ANYEVENT_/, keys %ENV}
1049 if ${^TAINT}; 1075 if ${^TAINT};
1050}
1051 1076
1052our $verbose = $ENV{PERL_ANYEVENT_VERBOSE}*1; 1077 $VERBOSE = $ENV{PERL_ANYEVENT_VERBOSE}*1;
1078
1079}
1080
1081our $MAX_SIGNAL_LATENCY = 10;
1053 1082
1054our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred 1083our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred
1055 1084
1056{ 1085{
1057 my $idx; 1086 my $idx;
1108 @post_detect = grep $_ != ${$_[0]}, @post_detect; 1137 @post_detect = grep $_ != ${$_[0]}, @post_detect;
1109} 1138}
1110 1139
1111sub detect() { 1140sub detect() {
1112 unless ($MODEL) { 1141 unless ($MODEL) {
1113 no strict 'refs';
1114 local $SIG{__DIE__}; 1142 local $SIG{__DIE__};
1115 1143
1116 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z]+)$/) { 1144 if ($ENV{PERL_ANYEVENT_MODEL} =~ /^([a-zA-Z]+)$/) {
1117 my $model = "AnyEvent::Impl::$1"; 1145 my $model = "AnyEvent::Impl::$1";
1118 if (eval "require $model") { 1146 if (eval "require $model") {
1119 $MODEL = $model; 1147 $MODEL = $model;
1120 warn "AnyEvent: loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it.\n" if $verbose > 1; 1148 warn "AnyEvent: loaded model '$model' (forced by \$ENV{PERL_ANYEVENT_MODEL}), using it.\n" if $VERBOSE >= 2;
1121 } else { 1149 } else {
1122 warn "AnyEvent: unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@" if $verbose; 1150 warn "AnyEvent: unable to load model '$model' (from \$ENV{PERL_ANYEVENT_MODEL}):\n$@" if $VERBOSE;
1123 } 1151 }
1124 } 1152 }
1125 1153
1126 # check for already loaded models 1154 # check for already loaded models
1127 unless ($MODEL) { 1155 unless ($MODEL) {
1128 for (@REGISTRY, @models) { 1156 for (@REGISTRY, @models) {
1129 my ($package, $model) = @$_; 1157 my ($package, $model) = @$_;
1130 if (${"$package\::VERSION"} > 0) { 1158 if (${"$package\::VERSION"} > 0) {
1131 if (eval "require $model") { 1159 if (eval "require $model") {
1132 $MODEL = $model; 1160 $MODEL = $model;
1133 warn "AnyEvent: autodetected model '$model', using it.\n" if $verbose > 1; 1161 warn "AnyEvent: autodetected model '$model', using it.\n" if $VERBOSE >= 2;
1134 last; 1162 last;
1135 } 1163 }
1136 } 1164 }
1137 } 1165 }
1138 1166
1143 my ($package, $model) = @$_; 1171 my ($package, $model) = @$_;
1144 if (eval "require $package" 1172 if (eval "require $package"
1145 and ${"$package\::VERSION"} > 0 1173 and ${"$package\::VERSION"} > 0
1146 and eval "require $model") { 1174 and eval "require $model") {
1147 $MODEL = $model; 1175 $MODEL = $model;
1148 warn "AnyEvent: autoprobed model '$model', using it.\n" if $verbose > 1; 1176 warn "AnyEvent: autoprobed model '$model', using it.\n" if $VERBOSE >= 2;
1149 last; 1177 last;
1150 } 1178 }
1151 } 1179 }
1152 1180
1153 $MODEL 1181 $MODEL
1198 1226
1199package AnyEvent::Base; 1227package AnyEvent::Base;
1200 1228
1201# default implementations for many methods 1229# default implementations for many methods
1202 1230
1203BEGIN { 1231sub _time {
1232 # probe for availability of Time::HiRes
1204 if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { 1233 if (eval "use Time::HiRes (); Time::HiRes::time (); 1") {
1234 warn "AnyEvent: using Time::HiRes for sub-second timing accuracy.\n" if $VERBOSE >= 8;
1205 *_time = \&Time::HiRes::time; 1235 *_time = \&Time::HiRes::time;
1206 # if (eval "use POSIX (); (POSIX::times())... 1236 # if (eval "use POSIX (); (POSIX::times())...
1207 } else { 1237 } else {
1238 warn "AnyEvent: using built-in time(), WARNING, no sub-second resolution!\n" if $VERBOSE;
1208 *_time = sub { time }; # epic fail 1239 *_time = sub { time }; # epic fail
1209 } 1240 }
1241
1242 &_time
1210} 1243}
1211 1244
1212sub time { _time } 1245sub time { _time }
1213sub now { _time } 1246sub now { _time }
1214sub now_update { } 1247sub now_update { }
1219 bless { @_ == 3 ? (_ae_cb => $_[2]) : () }, "AnyEvent::CondVar" 1252 bless { @_ == 3 ? (_ae_cb => $_[2]) : () }, "AnyEvent::CondVar"
1220} 1253}
1221 1254
1222# default implementation for ->signal 1255# default implementation for ->signal
1223 1256
1257our $HAVE_ASYNC_INTERRUPT;
1224our ($SIGPIPE_R, $SIGPIPE_W, %SIG_CB, %SIG_EV, $SIG_IO); 1258our ($SIGPIPE_R, $SIGPIPE_W, %SIG_CB, %SIG_EV, $SIG_IO);
1259our (%SIG_ASY, %SIG_ASY_W);
1260our ($SIG_COUNT, $SIG_TW);
1225 1261
1226sub _signal_exec { 1262sub _signal_exec {
1263 $HAVE_ASYNC_INTERRUPT
1264 ? $SIGPIPE_R->drain
1227 sysread $SIGPIPE_R, my $dummy, 4; 1265 : sysread $SIGPIPE_R, my $dummy, 9;
1228 1266
1229 while (%SIG_EV) { 1267 while (%SIG_EV) {
1230 for (keys %SIG_EV) { 1268 for (keys %SIG_EV) {
1231 delete $SIG_EV{$_}; 1269 delete $SIG_EV{$_};
1232 $_->() for values %{ $SIG_CB{$_} || {} }; 1270 $_->() for values %{ $SIG_CB{$_} || {} };
1233 } 1271 }
1234 } 1272 }
1235} 1273}
1236 1274
1275sub _signal {
1276 my (undef, %arg) = @_;
1277
1278 my $signal = uc $arg{signal}
1279 or Carp::croak "required option 'signal' is missing";
1280
1281 $SIG_CB{$signal}{$arg{cb}} = $arg{cb};
1282
1283 if ($HAVE_ASYNC_INTERRUPT) {
1284 # async::interrupt
1285
1286 $SIG_ASY{$signal} ||= do {
1287 my $asy = new Async::Interrupt
1288 cb => sub { undef $SIG_EV{$signal} },
1289 signal => $signal,
1290 pipe => [$SIGPIPE_R->filenos],
1291 ;
1292 $asy->pipe_autodrain (0);
1293
1294 $asy
1295 };
1296
1297 } else {
1298 # pure perl
1299
1300 $SIG{$signal} ||= sub {
1301 local $!;
1302 syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV;
1303 undef $SIG_EV{$signal};
1304 };
1305
1306 # can't do signal processing without introducing races in pure perl,
1307 # so limit the signal latency.
1308 ++$SIG_COUNT;
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 }
1315
1316 bless [$signal, $arg{cb}], "AnyEvent::Base::signal"
1317}
1318
1237sub signal { 1319sub signal {
1238 my (undef, %arg) = @_; 1320 # probe for availability of Async::Interrupt
1321 if (!$ENV{PERL_ANYEVENT_AVOID_ASYNC_INTERRUPT} && eval "use Async::Interrupt 0.6 (); 1") {
1322 warn "AnyEvent: using Async::Interrupt for race-free signal handling.\n" if $VERBOSE >= 8;
1239 1323
1240 unless ($SIGPIPE_R) { 1324 $HAVE_ASYNC_INTERRUPT = 1;
1325 $SIGPIPE_R = new Async::Interrupt::EventPipe;
1326 $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R->fileno, poll => "r", cb => \&_signal_exec);
1327
1328 } else {
1329 warn "AnyEvent: using emulated perl signal handling with latency timer.\n" if $VERBOSE >= 8;
1330
1241 require Fcntl; 1331 require Fcntl;
1242 1332
1243 if (AnyEvent::WIN32) { 1333 if (AnyEvent::WIN32) {
1244 require AnyEvent::Util; 1334 require AnyEvent::Util;
1245 1335
1260 or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n"; 1350 or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n";
1261 1351
1262 $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R, poll => "r", cb => \&_signal_exec); 1352 $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R, poll => "r", cb => \&_signal_exec);
1263 } 1353 }
1264 1354
1265 my $signal = uc $arg{signal} 1355 *signal = \&_signal;
1266 or Carp::croak "required option 'signal' is missing"; 1356 &signal
1267
1268 $SIG_CB{$signal}{$arg{cb}} = $arg{cb};
1269 $SIG{$signal} ||= sub {
1270 local $!;
1271 syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV;
1272 undef $SIG_EV{$signal};
1273 };
1274
1275 bless [$signal, $arg{cb}], "AnyEvent::Base::signal"
1276} 1357}
1277 1358
1278sub AnyEvent::Base::signal::DESTROY { 1359sub AnyEvent::Base::signal::DESTROY {
1279 my ($signal, $cb) = @{$_[0]}; 1360 my ($signal, $cb) = @{$_[0]};
1280 1361
1362 undef $SIG_TW
1363 unless --$SIG_COUNT;
1364
1281 delete $SIG_CB{$signal}{$cb}; 1365 delete $SIG_CB{$signal}{$cb};
1282 1366
1367 $HAVE_ASYNC_INTERRUPT
1368 ? delete $SIG_ASY{$signal}
1283 # delete doesn't work with older perls - they then 1369 : # delete doesn't work with older perls - they then
1284 # print weird messages, or just unconditionally exit 1370 # print weird messages, or just unconditionally exit
1285 # instead of getting the default action. 1371 # instead of getting the default action.
1372 undef $SIG{$signal}
1286 undef $SIG{$signal} unless keys %{ $SIG_CB{$signal} }; 1373 unless keys %{ $SIG_CB{$signal} };
1287} 1374}
1288 1375
1289# default implementation for ->child 1376# default implementation for ->child
1290 1377
1291our %PID_CB; 1378our %PID_CB;
1293our $CHLD_DELAY_W; 1380our $CHLD_DELAY_W;
1294our $WNOHANG; 1381our $WNOHANG;
1295 1382
1296sub _sigchld { 1383sub _sigchld {
1297 while (0 < (my $pid = waitpid -1, $WNOHANG)) { 1384 while (0 < (my $pid = waitpid -1, $WNOHANG)) {
1385 $_->($pid, $?)
1298 $_->($pid, $?) for (values %{ $PID_CB{$pid} || {} }), 1386 for values %{ $PID_CB{$pid} || {} },
1299 (values %{ $PID_CB{0} || {} }); 1387 values %{ $PID_CB{0} || {} };
1300 } 1388 }
1301} 1389}
1302 1390
1303sub child { 1391sub child {
1304 my (undef, %arg) = @_; 1392 my (undef, %arg) = @_;
1306 defined (my $pid = $arg{pid} + 0) 1394 defined (my $pid = $arg{pid} + 0)
1307 or Carp::croak "required option 'pid' is missing"; 1395 or Carp::croak "required option 'pid' is missing";
1308 1396
1309 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 1397 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
1310 1398
1399 # WNOHANG is almost cetrainly 1 everywhere
1400 $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/
1401 ? 1
1311 $WNOHANG ||= eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1; 1402 : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1;
1312 1403
1313 unless ($CHLD_W) { 1404 unless ($CHLD_W) {
1314 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_sigchld); 1405 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_sigchld);
1315 # child could be a zombie already, so make at least one round 1406 # child could be a zombie already, so make at least one round
1316 &_sigchld; 1407 &_sigchld;
1368 1459
1369our @ISA = AnyEvent::CondVar::Base::; 1460our @ISA = AnyEvent::CondVar::Base::;
1370 1461
1371package AnyEvent::CondVar::Base; 1462package AnyEvent::CondVar::Base;
1372 1463
1373use overload 1464#use overload
1374 '&{}' => sub { my $self = shift; sub { $self->send (@_) } }, 1465# '&{}' => sub { my $self = shift; sub { $self->send (@_) } },
1375 fallback => 1; 1466# fallback => 1;
1467
1468# save 300+ kilobytes by dirtily hardcoding overloading
1469${"AnyEvent::CondVar::Base::OVERLOAD"}{dummy}++; # Register with magic by touching.
1470*{'AnyEvent::CondVar::Base::()'} = sub { }; # "Make it findable via fetchmethod."
1471*{'AnyEvent::CondVar::Base::(&{}'} = sub { my $self = shift; sub { $self->send (@_) } }; # &{}
1472${'AnyEvent::CondVar::Base::()'} = 1; # fallback
1376 1473
1377our $WAITING; 1474our $WAITING;
1378 1475
1379sub _send { 1476sub _send {
1380 # nop 1477 # nop
1471C<PERL_ANYEVENT_MODEL>. 1568C<PERL_ANYEVENT_MODEL>.
1472 1569
1473When set to C<2> or higher, cause AnyEvent to report to STDERR which event 1570When set to C<2> or higher, cause AnyEvent to report to STDERR which event
1474model it chooses. 1571model it chooses.
1475 1572
1573When set to C<8> or higher, then AnyEvent will report extra information on
1574which optional modules it loads and how it implements certain features.
1575
1476=item C<PERL_ANYEVENT_STRICT> 1576=item C<PERL_ANYEVENT_STRICT>
1477 1577
1478AnyEvent does not do much argument checking by default, as thorough 1578AnyEvent does not do much argument checking by default, as thorough
1479argument checking is very costly. Setting this variable to a true value 1579argument checking is very costly. Setting this variable to a true value
1480will cause AnyEvent to load C<AnyEvent::Strict> and then to thoroughly 1580will cause AnyEvent to load C<AnyEvent::Strict> and then to thoroughly
1481check the arguments passed to most method calls. If it finds any problems, 1581check the arguments passed to most method calls. If it finds any problems,
1482it will croak. 1582it will croak.
1483 1583
1484In other words, enables "strict" mode. 1584In other words, enables "strict" mode.
1485 1585
1486Unlike C<use strict>, it is definitely recommended to keep it off in 1586Unlike C<use strict> (or it's modern cousin, C<< use L<common::sense>
1487production. Keeping C<PERL_ANYEVENT_STRICT=1> in your environment while 1587>>, it is definitely recommended to keep it off in production. Keeping
1488developing programs can be very useful, however. 1588C<PERL_ANYEVENT_STRICT=1> in your environment while developing programs
1589can be very useful, however.
1489 1590
1490=item C<PERL_ANYEVENT_MODEL> 1591=item C<PERL_ANYEVENT_MODEL>
1491 1592
1492This can be used to specify the event model to be used by AnyEvent, before 1593This can be used to specify the event model to be used by AnyEvent, before
1493auto detection and -probing kicks in. It must be a string consisting 1594auto detection and -probing kicks in. It must be a string consisting
1555 1656
1556When neither C<ca_file> nor C<ca_path> was specified during 1657When neither C<ca_file> nor C<ca_path> was specified during
1557L<AnyEvent::TLS> context creation, and either of these environment 1658L<AnyEvent::TLS> context creation, and either of these environment
1558variables exist, they will be used to specify CA certificate locations 1659variables exist, they will be used to specify CA certificate locations
1559instead of a system-dependent default. 1660instead of a system-dependent default.
1661
1662=item C<PERL_ANYEVENT_AVOID_GUARD> and C<PERL_ANYEVENT_AVOID_ASYNC_INTERRUPT>
1663
1664When these are set to C<1>, then the respective modules are not
1665loaded. Mostly good for testing AnyEvent itself.
1560 1666
1561=back 1667=back
1562 1668
1563=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE 1669=head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE
1564 1670
2132 if $SIG{CHLD} eq 'IGNORE'; 2238 if $SIG{CHLD} eq 'IGNORE';
2133 2239
2134$SIG{PIPE} = sub { } 2240$SIG{PIPE} = sub { }
2135 unless defined $SIG{PIPE}; 2241 unless defined $SIG{PIPE};
2136 2242
2243=head1 RECOMMENDED/OPTIONAL MODULES
2244
2245One of AnyEvent's main goals is to be 100% Pure-Perl(tm): only perl (and
2246it's built-in modules) are required to use it.
2247
2248That does not mean that AnyEvent won't take advantage of some additional
2249modules if they are installed.
2250
2251This section epxlains which additional modules will be used, and how they
2252affect AnyEvent's operetion.
2253
2254=over 4
2255
2256=item L<Async::Interrupt>
2257
2258This slightly arcane module is used to implement fast signal handling: To
2259my knowledge, there is no way to do completely race-free and quick
2260signal handling in pure perl. To ensure that signals still get
2261delivered, AnyEvent will start an interval timer to wake up perl (and
2262catch the signals) with soemd elay (default is 10 seconds, look for
2263C<$AnyEvent::MAX_SIGNAL_LATENCY>).
2264
2265If this module is available, then it will be used to implement signal
2266catching, which means that signals will not be delayed, and the event loop
2267will not be interrupted regularly, which is more efficient (And good for
2268battery life on laptops).
2269
2270This affects not just the pure-perl event loop, but also other event loops
2271that have no signal handling on their own (e.g. Glib, Tk, Qt).
2272
2273=item L<EV>
2274
2275This module isn't really "optional", as it is simply one of the backend
2276event loops that AnyEvent can use. However, it is simply the best event
2277loop available in terms of features, speed and stability: It supports
2278the AnyEvent API optimally, implements all the watcher types in XS, does
2279automatic timer adjustments even when no monotonic clock is available,
2280can take avdantage of advanced kernel interfaces such as C<epoll> and
2281C<kqueue>, and is the fastest backend I<by far>. You can even embed
2282L<Glib>/L<Gtk2> in it (or vice versa, see L<EV::Glib> and L<Glib::EV>).
2283
2284=item L<Guard>
2285
2286The guard module, when used, will be used to implement
2287C<AnyEvent::Util::guard>. This speeds up guards considerably (and uses a
2288lot less memory), but otherwise doesn't affect guard operation much. It is
2289purely used for performance.
2290
2291=item L<JSON> and L<JSON::XS>
2292
2293This module is required when you want to read or write JSON data via
2294L<AnyEvent::Handle>. It is also written in pure-perl, but can take
2295advantage of the ulta-high-speed L<JSON::XS> module when it is installed.
2296
2297In fact, L<AnyEvent::Handle> will use L<JSON::XS> by default if it is
2298installed.
2299
2300=item L<Net::SSLeay>
2301
2302Implementing TLS/SSL in Perl is certainly interesting, but not very
2303worthwhile: If this module is installed, then L<AnyEvent::Handle> (with
2304the help of L<AnyEvent::TLS>), gains the ability to do TLS/SSL.
2305
2306=item L<Time::HiRes>
2307
2308This module is part of perl since release 5.008. It will be used when the
2309chosen event library does not come with a timing source on it's own. The
2310pure-perl event loop (L<AnyEvent::Impl::Perl>) will additionally use it to
2311try to use a monotonic clock for timing stability.
2312
2313=back
2314
2315
2137=head1 FORK 2316=head1 FORK
2138 2317
2139Most event libraries are not fork-safe. The ones who are usually are 2318Most event libraries are not fork-safe. The ones who are usually are
2140because they rely on inefficient but fork-safe C<select> or C<poll> 2319because they rely on inefficient but fork-safe C<select> or C<poll>
2141calls. Only L<EV> is fully fork-aware. 2320calls. Only L<EV> is fully fork-aware.
2142 2321
2143If you have to fork, you must either do so I<before> creating your first 2322If you have to fork, you must either do so I<before> creating your first
2144watcher OR you must not use AnyEvent at all in the child. 2323watcher OR you must not use AnyEvent at all in the child OR you must do
2324something completely out of the scope of AnyEvent.
2145 2325
2146 2326
2147=head1 SECURITY CONSIDERATIONS 2327=head1 SECURITY CONSIDERATIONS
2148 2328
2149AnyEvent can be forced to load any event model via 2329AnyEvent can be forced to load any event model via

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines