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.360 by root, Sat Aug 13 22:44:05 2011 UTC vs.
Revision 1.361 by root, Sun Aug 14 01:38:14 2011 UTC

1206 1206
1207BEGIN { AnyEvent::common_sense } 1207BEGIN { AnyEvent::common_sense }
1208 1208
1209use Carp (); 1209use Carp ();
1210 1210
1211our $VERSION = '6.0'; 1211our $VERSION = '6.01';
1212our $MODEL; 1212our $MODEL;
1213 1213
1214our @ISA; 1214our @ISA;
1215 1215
1216our @REGISTRY; 1216our @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
1297our @isa_hook;
1298
1299sub _isa_set {
1300 my @pkg = ("AnyEvent", (grep defined, map $_->[0], @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
1310sub _isa_hook($$;$) {
1311 my ($i, $pkg, $reset_ae) = @_;
1312
1313 $isa_hook[$i] = [$pkg, $reset_ae];
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.
1299our @methods = qw(io timer time now now_update signal child idle condvar); 1320our @methods = qw(io timer time now now_update signal child idle condvar);
1300 1321
1301sub detect() { 1322sub 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
1499sub time { 1521sub 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
1520sub now_update { } 1543sub now_update { }
1521 1544
1522sub _poll { 1545sub _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}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines