loop#
Run the event loop: wait for events and call the watchers’ callbacks.
Also available as EV::run.
Synopsis#
EV::run; # until EV::break, or no active watcher is left
EV::run EV::RUN_ONCE; # wait for events once, handle them, return
EV::run EV::RUN_NOWAIT; # handle what is ready now, without waiting
What you get back#
True when it returned with work left - after EV::break, or with EV::RUN_ONCE or EV::RUN_NOWAIT - and false when no active watcher that keeps the loop alive was left.
Examples#
Wait for input, at most five seconds:
my $in = EV::io *STDIN, EV::READ, sub { print "input\n"; EV::break };
my $max = EV::timer 5, 0, sub { print "timeout\n"; EV::break };
EV::run;
Edge cases#
A watcher whose
keepaliveis off does not keepEV::runfrom returning.A callback may call
EV::runagain; the inner call returns first.EV::loopis the old name, from EV 3.
Differences from upstream#
Fully compatible with upstream. Covered by t/81-xs-native/EV/130-upstream-03_keepalive.t.
See also#
EV::break- makesEV::runreturnEV::once- waits for one event without a watcher object