… | |
… | |
46 | my ($w, $revents) = @_; |
46 | my ($w, $revents) = @_; |
47 | warn $w->path, " has changed somehow.\n"; |
47 | warn $w->path, " has changed somehow.\n"; |
48 | }; |
48 | }; |
49 | |
49 | |
50 | # MAINLOOP |
50 | # MAINLOOP |
51 | EV::run; # loop until EV::unloop is called or all watchers stop |
51 | EV::run; # loop until EV::break is called or all watchers stop |
52 | EV::run EV::RUN_ONCE; # block until at least one event could be handled |
52 | EV::run EV::RUN_ONCE; # block until at least one event could be handled |
53 | EV::run EV::RUN_NOWAIT; # try to handle same events, but do not block |
53 | EV::run EV::RUN_NOWAIT; # try to handle same events, but do not block |
54 | |
54 | |
55 | BEFORE YOU START USING THIS MODULE |
55 | BEFORE YOU START USING THIS MODULE |
56 | If you only need timer, I/O, signal, child and idle watchers and not the |
56 | If you only need timer, I/O, signal, child and idle watchers and not the |
… | |
… | |
236 | (EV::BACKEND_SELECT or EV::BACKEND_EPOLL). |
236 | (EV::BACKEND_SELECT or EV::BACKEND_EPOLL). |
237 | |
237 | |
238 | $active = EV::run [$flags] |
238 | $active = EV::run [$flags] |
239 | $active = $loop->run ([$flags]) |
239 | $active = $loop->run ([$flags]) |
240 | Begin checking for events and calling callbacks. It returns when a |
240 | Begin checking for events and calling callbacks. It returns when a |
241 | callback calls EV::unloop or the flasg are nonzero (in which case |
241 | callback calls EV::break or the flasg are nonzero (in which case the |
242 | the return value is true) or when there are no active watchers which |
242 | return value is true) or when there are no active watchers which |
243 | reference the loop (keepalive is true), in which case the return |
243 | reference the loop (keepalive is true), in which case the return |
244 | value will be false. The returnv alue can generally be interpreted |
244 | value will be false. The returnv alue can generally be interpreted |
245 | as "if true, there is more work left to do". |
245 | as "if true, there is more work left to do". |
246 | |
246 | |
247 | The $flags argument can be one of the following: |
247 | The $flags argument can be one of the following: |
… | |
… | |
558 | to system time: |
558 | to system time: |
559 | |
559 | |
560 | my $hourly = EV::periodic 0, 3600, 0, sub { print "once/hour\n" }; |
560 | my $hourly = EV::periodic 0, 3600, 0, sub { print "once/hour\n" }; |
561 | |
561 | |
562 | That doesn't mean there will always be 3600 seconds in between |
562 | That doesn't mean there will always be 3600 seconds in between |
563 | triggers, but only that the the clalback will be called when the |
563 | triggers, but only that the the callback will be called when the |
564 | system time shows a full hour (UTC). |
564 | system time shows a full hour (UTC). |
565 | |
565 | |
566 | Another way to think about it (for the mathematically inclined) |
566 | Another way to think about it (for the mathematically inclined) |
567 | is that EV::periodic will try to run the callback in this mode |
567 | is that EV::periodic will try to run the callback in this mode |
568 | at the next possible time where "$time = $at (mod $interval)", |
568 | at the next possible time where "$time = $at (mod $interval)", |