… | |
… | |
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 | |
510 | The callbacks are irrelevant, the only purpose of those watchers is |
511 | The callbacks are irrelevant (and are not even being called), the |
511 | to wake up the process as soon as one of those events occurs (socket |
512 | only purpose of those watchers is to wake up the process as soon as |
512 | readable, or timer timed out). The corresponding EV::check watcher will then |
513 | one of those events occurs (socket readable, or timer timed out). The |
513 | clean up: |
514 | corresponding 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 | |
522 | The callbacks of the created watchers will not be called as the watchers |
524 | The callbacks of the created watchers will not be called as the watchers |
523 | are destroyed before this cna happen (remember EV::check gets called |
525 | are destroyed before this cna happen (remember EV::check gets called |
524 | first). |
526 | first). |
… | |
… | |
527 | |
529 | |
528 | =back |
530 | =back |
529 | |
531 | |
530 | =head1 THREADS |
532 | =head1 THREADS |
531 | |
533 | |
532 | Threads are not supported by this in any way. Perl pseudo-threads is evil |
534 | Threads are not supported by this module in any way. Perl pseudo-threads |
533 | stuff and must die. |
535 | is evil stuff and must die. |
534 | |
536 | |
535 | =cut |
537 | =cut |
536 | |
538 | |
537 | our $DIED = sub { |
539 | our $DIED = sub { |
538 | warn "EV: error in callback (ignoring): $@"; |
540 | warn "EV: error in callback (ignoring): $@"; |