EV::Timer#
A relative timer, as EV::timer makes: its callback runs after a number of seconds, and optionally again at a repeat interval. These methods re-arm it and read or change its times; the methods all watchers share are EV::Watcher’s.
A timer counts on a clock that changes to the system time do not move. Starting one with a negative repeat interval croaks repeat value must be >= 0.
Synopsis#
# an inactivity timeout: re-armed on every read
my $timeout = EV::timer 30, 30, sub { warn "idle for 30 s\n" };
my $reader = EV::io $sock, EV::READ, sub { ...; $timeout->again };
printf "%.1f s left\n", $timeout->remaining;
Functions#
Timing#
again#
Re-arm a repeating timer from now - the way to keep a timeout from firing while there is activity.
remaining#
The seconds left until the timer fires, fractional; for an inactive timer, the time it was set to wait.
set#
Set both times anew: $w->set($after, $repeat) (repeat default 0). An active timer restarts, counting $after from now.
repeat#
The repeat interval; with an argument, set a new one and return the old. The timer is not restarted: an active timer uses the new interval from its next expiry.