… | |
… | |
1206 | |
1206 | |
1207 | BEGIN { AnyEvent::common_sense } |
1207 | BEGIN { AnyEvent::common_sense } |
1208 | |
1208 | |
1209 | use Carp (); |
1209 | use Carp (); |
1210 | |
1210 | |
1211 | our $VERSION = '5.34'; |
1211 | our $VERSION = '6.01'; |
1212 | our $MODEL; |
1212 | our $MODEL; |
1213 | |
1213 | |
1214 | our @ISA; |
1214 | our @ISA; |
1215 | |
1215 | |
1216 | our @REGISTRY; |
1216 | our @REGISTRY; |
… | |
… | |
1292 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # a bitch to autodetect |
1292 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # a bitch to autodetect |
1293 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
1293 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
1294 | [FLTK:: => AnyEvent::Impl::FLTK2::], |
1294 | [FLTK:: => AnyEvent::Impl::FLTK2::], |
1295 | ); |
1295 | ); |
1296 | |
1296 | |
|
|
1297 | our @isa_hook; |
|
|
1298 | |
|
|
1299 | sub _isa_set { |
|
|
1300 | my @pkg = ("AnyEvent", (map $_->[0], grep defined, @isa_hook), $MODEL); |
|
|
1301 | |
|
|
1302 | @{"$pkg[$_-1]::ISA"} = $pkg[$_] |
|
|
1303 | for 1 .. $#pkg; |
|
|
1304 | |
|
|
1305 | grep $_ && $_->[1], @isa_hook |
|
|
1306 | and AE::_reset (); |
|
|
1307 | } |
|
|
1308 | |
|
|
1309 | # used for hooking AnyEvent::Strict and AnyEvent::Debug::Wrap into the class hierarchy |
|
|
1310 | sub _isa_hook($$;$) { |
|
|
1311 | my ($i, $pkg, $reset_ae) = @_; |
|
|
1312 | |
|
|
1313 | $isa_hook[$i] = $pkg ? [$pkg, $reset_ae] : undef; |
|
|
1314 | |
|
|
1315 | _isa_set; |
|
|
1316 | } |
|
|
1317 | |
1297 | # all autoloaded methods reserve the complete glob, not just the method slot. |
1318 | # all autoloaded methods reserve the complete glob, not just the method slot. |
1298 | # due to bugs in perls method cache implementation. |
1319 | # due to bugs in perls method cache implementation. |
1299 | our @methods = qw(io timer time now now_update signal child idle condvar); |
1320 | our @methods = qw(io timer time now now_update signal child idle condvar); |
1300 | |
1321 | |
1301 | sub detect() { |
1322 | sub detect() { |
… | |
… | |
1360 | # free memory only needed for probing |
1381 | # free memory only needed for probing |
1361 | undef @models; |
1382 | undef @models; |
1362 | undef @REGISTRY; |
1383 | undef @REGISTRY; |
1363 | |
1384 | |
1364 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1385 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
1365 | unshift @ISA, $MODEL; |
|
|
1366 | |
1386 | |
1367 | # now nuke some methods that are overridden by the backend. |
1387 | # now nuke some methods that are overridden by the backend. |
1368 | # SUPER usage is not allowed in these. |
1388 | # SUPER usage is not allowed in these. |
1369 | for (qw(time signal child idle)) { |
1389 | for (qw(time signal child idle)) { |
1370 | undef &{"AnyEvent::Base::$_"} |
1390 | undef &{"AnyEvent::Base::$_"} |
1371 | if defined &{"$MODEL\::$_"}; |
1391 | if defined &{"$MODEL\::$_"}; |
1372 | } |
1392 | } |
|
|
1393 | |
|
|
1394 | _isa_set; |
1373 | |
1395 | |
1374 | if ($ENV{PERL_ANYEVENT_STRICT}) { |
1396 | if ($ENV{PERL_ANYEVENT_STRICT}) { |
1375 | require AnyEvent::Strict; |
1397 | require AnyEvent::Strict; |
1376 | } |
1398 | } |
1377 | |
1399 | |
… | |
… | |
1499 | sub time { |
1521 | sub time { |
1500 | eval q{ # poor man's autoloading {} |
1522 | eval q{ # poor man's autoloading {} |
1501 | # probe for availability of Time::HiRes |
1523 | # probe for availability of Time::HiRes |
1502 | if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { |
1524 | if (eval "use Time::HiRes (); Time::HiRes::time (); 1") { |
1503 | warn "AnyEvent: using Time::HiRes for sub-second timing accuracy.\n" if $VERBOSE >= 8; |
1525 | warn "AnyEvent: using Time::HiRes for sub-second timing accuracy.\n" if $VERBOSE >= 8; |
|
|
1526 | *time = sub { Time::HiRes::time () }; |
1504 | *AE::time = \&Time::HiRes::time; |
1527 | *AE::time = \& Time::HiRes::time ; |
1505 | # if (eval "use POSIX (); (POSIX::times())... |
1528 | # if (eval "use POSIX (); (POSIX::times())... |
1506 | } else { |
1529 | } else { |
1507 | warn "AnyEvent: using built-in time(), WARNING, no sub-second resolution!\n" if $VERBOSE; |
1530 | warn "AnyEvent: using built-in time(), WARNING, no sub-second resolution!\n" if $VERBOSE; |
|
|
1531 | *time = sub { CORE::time }; |
1508 | *AE::time = sub (){ time }; # epic fail |
1532 | *AE::time = sub (){ CORE::time }; |
1509 | } |
1533 | } |
1510 | |
1534 | |
1511 | *time = sub { AE::time }; # different prototypes |
1535 | *now = \&time; |
1512 | }; |
1536 | }; |
1513 | die if $@; |
1537 | die if $@; |
1514 | |
1538 | |
1515 | &time |
1539 | &time |
1516 | } |
1540 | } |
1517 | |
1541 | |
1518 | *now = \&time; |
1542 | *now = \&time; |
1519 | |
|
|
1520 | sub now_update { } |
1543 | sub now_update { } |
1521 | |
1544 | |
1522 | sub _poll { |
1545 | sub _poll { |
1523 | Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught"; |
1546 | Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught"; |
1524 | } |
1547 | } |
… | |
… | |
2397 | (even when used without AnyEvent), but most event loops have acceptable |
2420 | (even when used without AnyEvent), but most event loops have acceptable |
2398 | performance with or without AnyEvent. |
2421 | performance with or without AnyEvent. |
2399 | |
2422 | |
2400 | =item * The overhead AnyEvent adds is usually much smaller than the overhead of |
2423 | =item * The overhead AnyEvent adds is usually much smaller than the overhead of |
2401 | the actual event loop, only with extremely fast event loops such as EV |
2424 | the actual event loop, only with extremely fast event loops such as EV |
2402 | adds AnyEvent significant overhead. |
2425 | does AnyEvent add significant overhead. |
2403 | |
2426 | |
2404 | =item * You should avoid POE like the plague if you want performance or |
2427 | =item * You should avoid POE like the plague if you want performance or |
2405 | reasonable memory usage. |
2428 | reasonable memory usage. |
2406 | |
2429 | |
2407 | =back |
2430 | =back |