… | |
… | |
296 | =item $active = EV::run [$flags] |
296 | =item $active = EV::run [$flags] |
297 | |
297 | |
298 | =item $active = $loop->run ([$flags]) |
298 | =item $active = $loop->run ([$flags]) |
299 | |
299 | |
300 | Begin checking for events and calling callbacks. It returns when a |
300 | Begin checking for events and calling callbacks. It returns when a |
301 | callback calls EV::break or the flasg are nonzero (in which case the |
301 | callback calls EV::break or the flags are nonzero (in which case the |
302 | return value is true) or when there are no active watchers which reference |
302 | return value is true) or when there are no active watchers which reference |
303 | the loop (keepalive is true), in which case the return value will be |
303 | the loop (keepalive is true), in which case the return value will be |
304 | false. The returnv alue can generally be interpreted as "if true, there is |
304 | false. The return value can generally be interpreted as "if true, there is |
305 | more work left to do". |
305 | more work left to do". |
306 | |
306 | |
307 | The $flags argument can be one of the following: |
307 | The $flags argument can be one of the following: |
308 | |
308 | |
309 | 0 as above |
309 | 0 as above |
… | |
… | |
598 | |
598 | |
599 | =item $w = $loop->timer ($after, $repeat, $callback) |
599 | =item $w = $loop->timer ($after, $repeat, $callback) |
600 | |
600 | |
601 | =item $w = $loop->timer_ns ($after, $repeat, $callback) |
601 | =item $w = $loop->timer_ns ($after, $repeat, $callback) |
602 | |
602 | |
603 | Calls the callback after C<$after> seconds (which may be fractional). If |
603 | Calls the callback after C<$after> seconds (which may be fractional or |
604 | C<$repeat> is non-zero, the timer will be restarted (with the $repeat |
604 | negative). If C<$repeat> is non-zero, the timer will be restarted (with |
605 | value as $after) after the callback returns. |
605 | the $repeat value as $after) after the callback returns. |
606 | |
606 | |
607 | This means that the callback would be called roughly after C<$after> |
607 | This means that the callback would be called roughly after C<$after> |
608 | seconds, and then every C<$repeat> seconds. The timer does his best not |
608 | seconds, and then every C<$repeat> seconds. The timer does his best not |
609 | to drift, but it will not invoke the timer more often then once per event |
609 | to drift, but it will not invoke the timer more often then once per event |
610 | loop iteration, and might drift in other cases. If that isn't acceptable, |
610 | loop iteration, and might drift in other cases. If that isn't acceptable, |
… | |
… | |
682 | surpasses this time. |
682 | surpasses this time. |
683 | |
683 | |
684 | =item * repeating interval timer ($interval > 0, $reschedule_cb = 0) |
684 | =item * repeating interval timer ($interval > 0, $reschedule_cb = 0) |
685 | |
685 | |
686 | In this mode the watcher will always be scheduled to time out at the |
686 | In this mode the watcher will always be scheduled to time out at the |
687 | next C<$at + N * $interval> time (for some integer N) and then repeat, |
687 | next C<$at + N * $interval> time (for the lowest integer N) and then repeat, |
688 | regardless of any time jumps. |
688 | regardless of any time jumps. Note that, since C<N> can be negative, the |
|
|
689 | first trigger can happen before C<$at>. |
689 | |
690 | |
690 | This can be used to create timers that do not drift with respect to system |
691 | This can be used to create timers that do not drift with respect to system |
691 | time: |
692 | time: |
692 | |
693 | |
693 | my $hourly = EV::periodic 0, 3600, 0, sub { print "once/hour\n" }; |
694 | my $hourly = EV::periodic 0, 3600, 0, sub { print "once/hour\n" }; |