… | |
… | |
7 | |
7 | |
8 | =head1 SYNOPSIS |
8 | =head1 SYNOPSIS |
9 | |
9 | |
10 | use AnyEvent; |
10 | use AnyEvent; |
11 | |
11 | |
|
|
12 | # if you prefer function calls, look at the AE manpage for |
|
|
13 | # an alternative API. |
|
|
14 | |
12 | # file descriptor readable |
15 | # file handle or descriptor readable |
13 | my $w = AnyEvent->io (fh => $fh, poll => "r", cb => sub { ... }); |
16 | my $w = AnyEvent->io (fh => $fh, poll => "r", cb => sub { ... }); |
14 | |
17 | |
15 | # one-shot or repeating timers |
18 | # one-shot or repeating timers |
16 | my $w = AnyEvent->timer (after => $seconds, cb => sub { ... }); |
19 | my $w = AnyEvent->timer (after => $seconds, cb => sub { ... }); |
17 | my $w = AnyEvent->timer (after => $seconds, interval => $seconds, cb => ... |
20 | my $w = AnyEvent->timer (after => $seconds, interval => $seconds, cb => ... |
… | |
… | |
606 | eventually calls C<< -> send >>, and the "consumer side", which waits |
609 | eventually calls C<< -> send >>, and the "consumer side", which waits |
607 | for the send to occur. |
610 | for the send to occur. |
608 | |
611 | |
609 | Example: wait for a timer. |
612 | Example: wait for a timer. |
610 | |
613 | |
611 | # wait till the result is ready |
614 | # condition: "wait till the timer is fired" |
612 | my $result_ready = AnyEvent->condvar; |
615 | my $timer_fired = AnyEvent->condvar; |
613 | |
616 | |
614 | # do something such as adding a timer |
617 | # create the timer - we could wait for, say |
615 | # or socket watcher the calls $result_ready->send |
618 | # a handle becomign ready, or even an |
616 | # when the "result" is ready. |
619 | # AnyEvent::HTTP request to finish, but |
617 | # in this case, we simply use a timer: |
620 | # in this case, we simply use a timer: |
618 | my $w = AnyEvent->timer ( |
621 | my $w = AnyEvent->timer ( |
619 | after => 1, |
622 | after => 1, |
620 | cb => sub { $result_ready->send }, |
623 | cb => sub { $timer_fired->send }, |
621 | ); |
624 | ); |
622 | |
625 | |
623 | # this "blocks" (while handling events) till the callback |
626 | # this "blocks" (while handling events) till the callback |
624 | # calls ->send |
627 | # calls ->send |
625 | $result_ready->recv; |
628 | $timer_fired->recv; |
626 | |
629 | |
627 | Example: wait for a timer, but take advantage of the fact that condition |
630 | Example: wait for a timer, but take advantage of the fact that condition |
628 | variables are also callable directly. |
631 | variables are also callable directly. |
629 | |
632 | |
630 | my $done = AnyEvent->condvar; |
633 | my $done = AnyEvent->condvar; |
… | |
… | |
1054 | =head1 OTHER MODULES |
1057 | =head1 OTHER MODULES |
1055 | |
1058 | |
1056 | The following is a non-exhaustive list of additional modules that use |
1059 | The following is a non-exhaustive list of additional modules that use |
1057 | AnyEvent as a client and can therefore be mixed easily with other AnyEvent |
1060 | AnyEvent as a client and can therefore be mixed easily with other AnyEvent |
1058 | modules and other event loops in the same program. Some of the modules |
1061 | modules and other event loops in the same program. Some of the modules |
1059 | come with AnyEvent, most are available via CPAN. |
1062 | come as part of AnyEvent, the others are available via CPAN. |
1060 | |
1063 | |
1061 | =over 4 |
1064 | =over 4 |
1062 | |
1065 | |
1063 | =item L<AnyEvent::Util> |
1066 | =item L<AnyEvent::Util> |
1064 | |
1067 | |
… | |
… | |
1079 | |
1082 | |
1080 | =item L<AnyEvent::DNS> |
1083 | =item L<AnyEvent::DNS> |
1081 | |
1084 | |
1082 | Provides rich asynchronous DNS resolver capabilities. |
1085 | Provides rich asynchronous DNS resolver capabilities. |
1083 | |
1086 | |
|
|
1087 | =item L<AnyEvent::HTTP>, L<AnyEvent::IRC>, L<AnyEvent::XMPP>, L<AnyEvent::GPSD>, L<AnyEvent::IGS>, L<AnyEvent::FCP> |
|
|
1088 | |
|
|
1089 | Implement event-based interfaces to the protocols of the same name (for |
|
|
1090 | the curious, IGS is the International Go Server and FCP is the Freenet |
|
|
1091 | Client Protocol). |
|
|
1092 | |
|
|
1093 | =item L<AnyEvent::Handle::UDP> |
|
|
1094 | |
|
|
1095 | Here be danger! |
|
|
1096 | |
|
|
1097 | As Pauli would put it, "Not only is it not right, it's not even wrong!" - |
|
|
1098 | there are so many things wrong with AnyEvent::Handle::UDP, most notably |
|
|
1099 | it's use of a stream-based API with a protocol that isn't streamable, that |
|
|
1100 | the only way to improve it is to delete it. |
|
|
1101 | |
|
|
1102 | It features data corruption (but typically only under load) and general |
|
|
1103 | confusion. On top, the author is not only clueless about UDP but also |
|
|
1104 | fact-resistant - some gems of his understanding: "connect doesn't work |
|
|
1105 | with UDP", "UDP packets are not IP packets", "UDP only has datagrams, not |
|
|
1106 | packets", "I don't need to implement proper error checking as UDP doesn't |
|
|
1107 | support error checking" and so on - he doesn't even understand what's |
|
|
1108 | wrong with his module when it is explained to him. |
|
|
1109 | |
1084 | =item L<AnyEvent::HTTP> |
1110 | =item L<AnyEvent::DBI> |
1085 | |
1111 | |
1086 | A simple-to-use HTTP library that is capable of making a lot of concurrent |
1112 | Executes L<DBI> requests asynchronously in a proxy process for you, |
1087 | HTTP requests. |
1113 | notifying you in an event-bnased way when the operation is finished. |
|
|
1114 | |
|
|
1115 | =item L<AnyEvent::AIO> |
|
|
1116 | |
|
|
1117 | Truly asynchronous (as opposed to non-blocking) I/O, should be in the |
|
|
1118 | toolbox of every event programmer. AnyEvent::AIO transparently fuses |
|
|
1119 | L<IO::AIO> and AnyEvent together, giving AnyEvent access to event-based |
|
|
1120 | file I/O, and much more. |
1088 | |
1121 | |
1089 | =item L<AnyEvent::HTTPD> |
1122 | =item L<AnyEvent::HTTPD> |
1090 | |
1123 | |
1091 | Provides a simple web application server framework. |
1124 | A simple embedded webserver. |
1092 | |
1125 | |
1093 | =item L<AnyEvent::FastPing> |
1126 | =item L<AnyEvent::FastPing> |
1094 | |
1127 | |
1095 | The fastest ping in the west. |
1128 | The fastest ping in the west. |
1096 | |
|
|
1097 | =item L<AnyEvent::DBI> |
|
|
1098 | |
|
|
1099 | Executes L<DBI> requests asynchronously in a proxy process. |
|
|
1100 | |
|
|
1101 | =item L<AnyEvent::AIO> |
|
|
1102 | |
|
|
1103 | Truly asynchronous I/O, should be in the toolbox of every event |
|
|
1104 | programmer. AnyEvent::AIO transparently fuses L<IO::AIO> and AnyEvent |
|
|
1105 | together. |
|
|
1106 | |
|
|
1107 | =item L<AnyEvent::BDB> |
|
|
1108 | |
|
|
1109 | Truly asynchronous Berkeley DB access. AnyEvent::BDB transparently fuses |
|
|
1110 | L<BDB> and AnyEvent together. |
|
|
1111 | |
|
|
1112 | =item L<AnyEvent::GPSD> |
|
|
1113 | |
|
|
1114 | A non-blocking interface to gpsd, a daemon delivering GPS information. |
|
|
1115 | |
|
|
1116 | =item L<AnyEvent::IRC> |
|
|
1117 | |
|
|
1118 | AnyEvent based IRC client module family (replacing the older Net::IRC3). |
|
|
1119 | |
|
|
1120 | =item L<AnyEvent::XMPP> |
|
|
1121 | |
|
|
1122 | AnyEvent based XMPP (Jabber protocol) module family (replacing the older |
|
|
1123 | Net::XMPP2>. |
|
|
1124 | |
|
|
1125 | =item L<AnyEvent::IGS> |
|
|
1126 | |
|
|
1127 | A non-blocking interface to the Internet Go Server protocol (used by |
|
|
1128 | L<App::IGS>). |
|
|
1129 | |
|
|
1130 | =item L<Net::FCP> |
|
|
1131 | |
|
|
1132 | AnyEvent-based implementation of the Freenet Client Protocol, birthplace |
|
|
1133 | of AnyEvent. |
|
|
1134 | |
|
|
1135 | =item L<Event::ExecFlow> |
|
|
1136 | |
|
|
1137 | High level API for event-based execution flow control. |
|
|
1138 | |
1129 | |
1139 | =item L<Coro> |
1130 | =item L<Coro> |
1140 | |
1131 | |
1141 | Has special support for AnyEvent via L<Coro::AnyEvent>. |
1132 | Has special support for AnyEvent via L<Coro::AnyEvent>. |
1142 | |
1133 | |
… | |
… | |
1156 | |
1147 | |
1157 | BEGIN { AnyEvent::common_sense } |
1148 | BEGIN { AnyEvent::common_sense } |
1158 | |
1149 | |
1159 | use Carp (); |
1150 | use Carp (); |
1160 | |
1151 | |
1161 | our $VERSION = '5.251'; |
1152 | our $VERSION = '5.261'; |
1162 | our $MODEL; |
1153 | our $MODEL; |
1163 | |
1154 | |
1164 | our $AUTOLOAD; |
1155 | our $AUTOLOAD; |
1165 | our @ISA; |
1156 | our @ISA; |
1166 | |
1157 | |
… | |
… | |
1169 | our $VERBOSE; |
1160 | our $VERBOSE; |
1170 | |
1161 | |
1171 | BEGIN { |
1162 | BEGIN { |
1172 | require "AnyEvent/constants.pl"; |
1163 | require "AnyEvent/constants.pl"; |
1173 | |
1164 | |
1174 | eval "sub TAINT (){" . (${^TAINT} *1) . "}"; |
1165 | eval "sub TAINT (){" . (${^TAINT}*1) . "}"; |
1175 | |
1166 | |
1176 | delete @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} |
1167 | delete @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} |
1177 | if ${^TAINT}; |
1168 | if ${^TAINT}; |
1178 | |
1169 | |
1179 | $VERBOSE = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
1170 | $VERBOSE = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
… | |
… | |
1222 | our @post_detect; |
1213 | our @post_detect; |
1223 | |
1214 | |
1224 | sub post_detect(&) { |
1215 | sub post_detect(&) { |
1225 | my ($cb) = @_; |
1216 | my ($cb) = @_; |
1226 | |
1217 | |
1227 | if ($MODEL) { |
|
|
1228 | $cb->(); |
|
|
1229 | |
|
|
1230 | undef |
|
|
1231 | } else { |
|
|
1232 | push @post_detect, $cb; |
1218 | push @post_detect, $cb; |
1233 | |
1219 | |
1234 | defined wantarray |
1220 | defined wantarray |
1235 | ? bless \$cb, "AnyEvent::Util::postdetect" |
1221 | ? bless \$cb, "AnyEvent::Util::postdetect" |
1236 | : () |
1222 | : () |
1237 | } |
|
|
1238 | } |
1223 | } |
1239 | |
1224 | |
1240 | sub AnyEvent::Util::postdetect::DESTROY { |
1225 | sub AnyEvent::Util::postdetect::DESTROY { |
1241 | @post_detect = grep $_ != ${$_[0]}, @post_detect; |
1226 | @post_detect = grep $_ != ${$_[0]}, @post_detect; |
1242 | } |
1227 | } |
… | |
… | |
1295 | @models = (); # free probe data |
1280 | @models = (); # free probe data |
1296 | |
1281 | |
1297 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1282 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1298 | unshift @ISA, $MODEL; |
1283 | unshift @ISA, $MODEL; |
1299 | |
1284 | |
|
|
1285 | # now nuke some methods that are overriden by the backend. |
|
|
1286 | # SUPER is not allowed. |
|
|
1287 | for (qw(time signal child idle)) { |
|
|
1288 | undef &{"AnyEvent::Base::$_"} |
|
|
1289 | if defined &{"$MODEL\::$_"}; |
|
|
1290 | } |
|
|
1291 | |
1300 | require AnyEvent::Strict if $ENV{PERL_ANYEVENT_STRICT}; |
1292 | require AnyEvent::Strict if $ENV{PERL_ANYEVENT_STRICT}; |
1301 | |
1293 | |
1302 | (shift @post_detect)->() while @post_detect; |
1294 | (shift @post_detect)->() while @post_detect; |
|
|
1295 | |
|
|
1296 | *post_detect = sub(&) { |
|
|
1297 | shift->(); |
|
|
1298 | |
|
|
1299 | undef |
|
|
1300 | }; |
1303 | |
1301 | |
1304 | $MODEL |
1302 | $MODEL |
1305 | } |
1303 | } |
1306 | |
1304 | |
1307 | sub AUTOLOAD { |
1305 | sub AUTOLOAD { |
… | |
… | |
1335 | |
1333 | |
1336 | =head1 SIMPLIFIED AE API |
1334 | =head1 SIMPLIFIED AE API |
1337 | |
1335 | |
1338 | Starting with version 5.0, AnyEvent officially supports a second, much |
1336 | Starting with version 5.0, AnyEvent officially supports a second, much |
1339 | simpler, API that is designed to reduce the calling, typing and memory |
1337 | simpler, API that is designed to reduce the calling, typing and memory |
1340 | overhead. |
1338 | overhead by using function call syntax and a fixed number of parameters. |
1341 | |
1339 | |
1342 | See the L<AE> manpage for details. |
1340 | See the L<AE> manpage for details. |
1343 | |
1341 | |
1344 | =cut |
1342 | =cut |
1345 | |
1343 | |
1346 | package AE; |
1344 | package AE; |
1347 | |
1345 | |
1348 | our $VERSION = $AnyEvent::VERSION; |
1346 | our $VERSION = $AnyEvent::VERSION; |
|
|
1347 | |
|
|
1348 | # fall back to the main API by default - backends and AnyEvent::Base |
|
|
1349 | # implementations can overwrite these. |
1349 | |
1350 | |
1350 | sub io($$$) { |
1351 | sub io($$$) { |
1351 | AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) |
1352 | AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) |
1352 | } |
1353 | } |
1353 | |
1354 | |
… | |
… | |
1385 | |
1386 | |
1386 | package AnyEvent::Base; |
1387 | package AnyEvent::Base; |
1387 | |
1388 | |
1388 | # default implementations for many methods |
1389 | # default implementations for many methods |
1389 | |
1390 | |
1390 | sub _time() { |
1391 | sub time { |
1391 | eval q{ # poor man's autoloading |
1392 | eval q{ # poor man's autoloading {} |
1392 | # probe for availability of Time::HiRes |
1393 | # probe for availability of Time::HiRes |
1393 | if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { |
1394 | if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { |
1394 | warn "AnyEvent: using Time::HiRes for sub-second timing accuracy.\n" if $VERBOSE >= 8; |
1395 | warn "AnyEvent: using Time::HiRes for sub-second timing accuracy.\n" if $VERBOSE >= 8; |
1395 | *_time = \&Time::HiRes::time; |
1396 | *AE::time = \&Time::HiRes::time; |
1396 | # if (eval "use POSIX (); (POSIX::times())... |
1397 | # if (eval "use POSIX (); (POSIX::times())... |
1397 | } else { |
1398 | } else { |
1398 | warn "AnyEvent: using built-in time(), WARNING, no sub-second resolution!\n" if $VERBOSE; |
1399 | warn "AnyEvent: using built-in time(), WARNING, no sub-second resolution!\n" if $VERBOSE; |
1399 | *_time = sub (){ time }; # epic fail |
1400 | *AE::time = sub (){ time }; # epic fail |
1400 | } |
1401 | } |
|
|
1402 | |
|
|
1403 | *time = sub { AE::time }; # different prototypes |
1401 | }; |
1404 | }; |
1402 | die if $@; |
1405 | die if $@; |
1403 | |
1406 | |
1404 | &_time |
1407 | &time |
1405 | } |
1408 | } |
1406 | |
1409 | |
1407 | sub time { _time } |
1410 | *now = \&time; |
1408 | sub now { _time } |
1411 | |
1409 | sub now_update { } |
1412 | sub now_update { } |
1410 | |
1413 | |
1411 | # default implementation for ->condvar |
1414 | # default implementation for ->condvar |
1412 | |
1415 | |
1413 | sub condvar { |
1416 | sub condvar { |
|
|
1417 | eval q{ # poor man's autoloading {} |
|
|
1418 | *condvar = sub { |
1414 | bless { @_ == 3 ? (_ae_cb => $_[2]) : () }, "AnyEvent::CondVar" |
1419 | bless { @_ == 3 ? (_ae_cb => $_[2]) : () }, "AnyEvent::CondVar" |
|
|
1420 | }; |
|
|
1421 | |
|
|
1422 | *AE::cv = sub (;&) { |
|
|
1423 | bless { @_ ? (_ae_cb => shift) : () }, "AnyEvent::CondVar" |
|
|
1424 | }; |
|
|
1425 | }; |
|
|
1426 | die if $@; |
|
|
1427 | |
|
|
1428 | &condvar |
1415 | } |
1429 | } |
1416 | |
1430 | |
1417 | # default implementation for ->signal |
1431 | # default implementation for ->signal |
1418 | |
1432 | |
1419 | our $HAVE_ASYNC_INTERRUPT; |
1433 | our $HAVE_ASYNC_INTERRUPT; |
… | |
… | |
1449 | undef $SIG_TW |
1463 | undef $SIG_TW |
1450 | unless --$SIG_COUNT; |
1464 | unless --$SIG_COUNT; |
1451 | } |
1465 | } |
1452 | |
1466 | |
1453 | our $_sig_name_init; $_sig_name_init = sub { |
1467 | our $_sig_name_init; $_sig_name_init = sub { |
1454 | eval q{ # poor man's autoloading |
1468 | eval q{ # poor man's autoloading {} |
1455 | undef $_sig_name_init; |
1469 | undef $_sig_name_init; |
1456 | |
1470 | |
1457 | if (_have_async_interrupt) { |
1471 | if (_have_async_interrupt) { |
1458 | *sig2num = \&Async::Interrupt::sig2num; |
1472 | *sig2num = \&Async::Interrupt::sig2num; |
1459 | *sig2name = \&Async::Interrupt::sig2name; |
1473 | *sig2name = \&Async::Interrupt::sig2name; |
… | |
… | |
1513 | or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n"; |
1527 | or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n"; |
1514 | |
1528 | |
1515 | $SIG_IO = AE::io $SIGPIPE_R, 0, \&_signal_exec; |
1529 | $SIG_IO = AE::io $SIGPIPE_R, 0, \&_signal_exec; |
1516 | } |
1530 | } |
1517 | |
1531 | |
1518 | *signal = sub { |
1532 | *signal = $HAVE_ASYNC_INTERRUPT |
|
|
1533 | ? sub { |
1519 | my (undef, %arg) = @_; |
1534 | my (undef, %arg) = @_; |
1520 | |
1535 | |
1521 | my $signal = uc $arg{signal} |
|
|
1522 | or Carp::croak "required option 'signal' is missing"; |
|
|
1523 | |
|
|
1524 | if ($HAVE_ASYNC_INTERRUPT) { |
|
|
1525 | # async::interrupt |
1536 | # async::interrupt |
1526 | |
|
|
1527 | $signal = sig2num $signal; |
1537 | my $signal = sig2num $arg{signal}; |
1528 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1538 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1529 | |
1539 | |
1530 | $SIG_ASY{$signal} ||= new Async::Interrupt |
1540 | $SIG_ASY{$signal} ||= new Async::Interrupt |
1531 | cb => sub { undef $SIG_EV{$signal} }, |
1541 | cb => sub { undef $SIG_EV{$signal} }, |
1532 | signal => $signal, |
1542 | signal => $signal, |
1533 | pipe => [$SIGPIPE_R->filenos], |
1543 | pipe => [$SIGPIPE_R->filenos], |
1534 | pipe_autodrain => 0, |
1544 | pipe_autodrain => 0, |
1535 | ; |
1545 | ; |
1536 | |
1546 | |
1537 | } else { |
1547 | bless [$signal, $arg{cb}], "AnyEvent::Base::signal" |
|
|
1548 | } |
|
|
1549 | : sub { |
|
|
1550 | my (undef, %arg) = @_; |
|
|
1551 | |
1538 | # pure perl |
1552 | # pure perl |
1539 | |
|
|
1540 | # AE::Util has been loaded in signal |
|
|
1541 | $signal = sig2name $signal; |
1553 | my $signal = sig2name $arg{signal}; |
1542 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1554 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1543 | |
1555 | |
1544 | $SIG{$signal} ||= sub { |
1556 | $SIG{$signal} ||= sub { |
1545 | local $!; |
1557 | local $!; |
1546 | syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV; |
1558 | syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV; |
1547 | undef $SIG_EV{$signal}; |
1559 | undef $SIG_EV{$signal}; |
1548 | }; |
1560 | }; |
1549 | |
1561 | |
1550 | # can't do signal processing without introducing races in pure perl, |
1562 | # can't do signal processing without introducing races in pure perl, |
1551 | # so limit the signal latency. |
1563 | # so limit the signal latency. |
1552 | _sig_add; |
1564 | _sig_add; |
1553 | } |
|
|
1554 | |
1565 | |
1555 | bless [$signal, $arg{cb}], "AnyEvent::Base::signal" |
1566 | bless [$signal, $arg{cb}], "AnyEvent::Base::signal" |
|
|
1567 | } |
1556 | }; |
1568 | ; |
1557 | |
1569 | |
1558 | *AnyEvent::Base::signal::DESTROY = sub { |
1570 | *AnyEvent::Base::signal::DESTROY = sub { |
1559 | my ($signal, $cb) = @{$_[0]}; |
1571 | my ($signal, $cb) = @{$_[0]}; |
1560 | |
1572 | |
1561 | _sig_del; |
1573 | _sig_del; |
… | |
… | |
2057 | |
2069 | |
2058 | The actual code goes further and collects all errors (C<die>s, exceptions) |
2070 | The actual code goes further and collects all errors (C<die>s, exceptions) |
2059 | that occurred during request processing. The C<result> method detects |
2071 | that occurred during request processing. The C<result> method detects |
2060 | whether an exception as thrown (it is stored inside the $txn object) |
2072 | whether an exception as thrown (it is stored inside the $txn object) |
2061 | and just throws the exception, which means connection errors and other |
2073 | and just throws the exception, which means connection errors and other |
2062 | problems get reported tot he code that tries to use the result, not in a |
2074 | problems get reported to the code that tries to use the result, not in a |
2063 | random callback. |
2075 | random callback. |
2064 | |
2076 | |
2065 | All of this enables the following usage styles: |
2077 | All of this enables the following usage styles: |
2066 | |
2078 | |
2067 | 1. Blocking: |
2079 | 1. Blocking: |
… | |
… | |
2524 | automatic timer adjustments even when no monotonic clock is available, |
2536 | automatic timer adjustments even when no monotonic clock is available, |
2525 | can take avdantage of advanced kernel interfaces such as C<epoll> and |
2537 | can take avdantage of advanced kernel interfaces such as C<epoll> and |
2526 | C<kqueue>, and is the fastest backend I<by far>. You can even embed |
2538 | C<kqueue>, and is the fastest backend I<by far>. You can even embed |
2527 | L<Glib>/L<Gtk2> in it (or vice versa, see L<EV::Glib> and L<Glib::EV>). |
2539 | L<Glib>/L<Gtk2> in it (or vice versa, see L<EV::Glib> and L<Glib::EV>). |
2528 | |
2540 | |
|
|
2541 | If you only use backends that rely on another event loop (e.g. C<Tk>), |
|
|
2542 | then this module will do nothing for you. |
|
|
2543 | |
2529 | =item L<Guard> |
2544 | =item L<Guard> |
2530 | |
2545 | |
2531 | The guard module, when used, will be used to implement |
2546 | The guard module, when used, will be used to implement |
2532 | C<AnyEvent::Util::guard>. This speeds up guards considerably (and uses a |
2547 | C<AnyEvent::Util::guard>. This speeds up guards considerably (and uses a |
2533 | lot less memory), but otherwise doesn't affect guard operation much. It is |
2548 | lot less memory), but otherwise doesn't affect guard operation much. It is |
2534 | purely used for performance. |
2549 | purely used for performance. |
2535 | |
2550 | |
2536 | =item L<JSON> and L<JSON::XS> |
2551 | =item L<JSON> and L<JSON::XS> |
2537 | |
2552 | |
2538 | One of these modules is required when you want to read or write JSON data |
2553 | One of these modules is required when you want to read or write JSON data |
2539 | via L<AnyEvent::Handle>. It is also written in pure-perl, but can take |
2554 | via L<AnyEvent::Handle>. L<JSON> is also written in pure-perl, but can take |
2540 | advantage of the ultra-high-speed L<JSON::XS> module when it is installed. |
2555 | advantage of the ultra-high-speed L<JSON::XS> module when it is installed. |
2541 | |
|
|
2542 | In fact, L<AnyEvent::Handle> will use L<JSON::XS> by default if it is |
|
|
2543 | installed. |
|
|
2544 | |
2556 | |
2545 | =item L<Net::SSLeay> |
2557 | =item L<Net::SSLeay> |
2546 | |
2558 | |
2547 | Implementing TLS/SSL in Perl is certainly interesting, but not very |
2559 | Implementing TLS/SSL in Perl is certainly interesting, but not very |
2548 | worthwhile: If this module is installed, then L<AnyEvent::Handle> (with |
2560 | worthwhile: If this module is installed, then L<AnyEvent::Handle> (with |