ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.pm
(Generate patch)

Comparing EV/EV.pm (file contents):
Revision 1.39 by root, Tue Nov 13 03:12:52 2007 UTC vs.
Revision 1.45 by root, Fri Nov 23 03:59:23 2007 UTC

57package EV; 57package EV;
58 58
59use strict; 59use strict;
60 60
61BEGIN { 61BEGIN {
62 our $VERSION = '0.9'; 62 our $VERSION = '1.2';
63 use XSLoader; 63 use XSLoader;
64 XSLoader::load "EV", $VERSION; 64 XSLoader::load "EV", $VERSION;
65} 65}
66 66
67@EV::Io::ISA = 67@EV::Io::ISA =
93 93
94Returns the time the last event loop iteration has been started. This 94Returns the time the last event loop iteration has been started. This
95is the time that (relative) timers are based on, and refering to it is 95is the time that (relative) timers are based on, and refering to it is
96usually faster then calling EV::time. 96usually faster then calling EV::time.
97 97
98=item $method = EV::ev_method 98=item $method = EV::method
99 99
100Returns an integer describing the backend used by libev (EV::METHOD_SELECT 100Returns an integer describing the backend used by libev (EV::METHOD_SELECT
101or EV::METHOD_EPOLL). 101or EV::METHOD_EPOLL).
102 102
103=item EV::loop [$flags] 103=item EV::loop [$flags]
493 # do nothing unless active 493 # do nothing unless active
494 $dispatcher->{_event_queue_h} 494 $dispatcher->{_event_queue_h}
495 or return; 495 or return;
496 496
497 # make the dispatcher handle any outstanding stuff 497 # make the dispatcher handle any outstanding stuff
498 ... not shown
498 499
499 # create an IO watcher for each and every socket 500 # create an IO watcher for each and every socket
500 @snmp_watcher = ( 501 @snmp_watcher = (
501 (map { EV::io $_, EV::READ, sub { } } 502 (map { EV::io $_, EV::READ, sub { } }
502 keys %{ $dispatcher->{_descriptors} }), 503 keys %{ $dispatcher->{_descriptors} }),
504
505 EV::timer +($event->[Net::SNMP::Dispatcher::_ACTIVE]
506 ? $event->[Net::SNMP::Dispatcher::_TIME] - EV::now : 0),
507 0, sub { },
503 ); 508 );
504
505 # if there are any timeouts, also create a timer
506 push @snmp_watcher, EV::timer $event->[Net::SNMP::Dispatcher::_TIME] - EV::now, 0, sub { }
507 if $event->[Net::SNMP::Dispatcher::_ACTIVE];
508 }; 509 };
509 510
510The callbacks are irrelevant, the only purpose of those watchers is 511The callbacks are irrelevant (and are not even being called), the
511to wake up the process as soon as one of those events occurs (socket 512only purpose of those watchers is to wake up the process as soon as
512readable, or timer timed out). The corresponding EV::check watcher will then 513one of those events occurs (socket readable, or timer timed out). The
513clean up: 514corresponding EV::check watcher will then clean up:
514 515
515 our $snmp_check = EV::check sub { 516 our $snmp_check = EV::check sub {
516 # destroy all watchers 517 # destroy all watchers
517 @snmp_watcher = (); 518 @snmp_watcher = ();
518 519
519 # make the dispatcher handle any new stuff 520 # make the dispatcher handle any new stuff
521 ... not shown
520 }; 522 };
521 523
522The callbacks of the created watchers will not be called as the watchers 524The callbacks of the created watchers will not be called as the watchers
523are destroyed before this cna happen (remember EV::check gets called 525are destroyed before this cna happen (remember EV::check gets called
524first). 526first).
527 529
528=back 530=back
529 531
530=head1 THREADS 532=head1 THREADS
531 533
532Threads are not supported by this in any way. Perl pseudo-threads is evil 534Threads are not supported by this module in any way. Perl pseudo-threads
533stuff and must die. 535is evil stuff and must die.
534 536
535=cut 537=cut
536 538
537our $DIED = sub { 539our $DIED = sub {
538 warn "EV: error in callback (ignoring): $@"; 540 warn "EV: error in callback (ignoring): $@";
543 545
5441; 5461;
545 547
546=head1 SEE ALSO 548=head1 SEE ALSO
547 549
548 L<EV::DNS>, L<EV::AnyEvent>. 550 L<EV::DNS>.
549 551
550=head1 AUTHOR 552=head1 AUTHOR
551 553
552 Marc Lehmann <schmorp@schmorp.de> 554 Marc Lehmann <schmorp@schmorp.de>
553 http://home.schmorp.de/ 555 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines