NAME
Linux::Event::Timer - Thin wrapper around Linux::FD::Timer (timerfd)
SYNOPSIS
use Linux::Event::Timer;
# Create unarmed
my $t = Linux::Event::Timer->new;
# Arm one-shot
$t->after(0.25);
# Arm periodic
$t->every(1.0);
# Constructor arming
my $t2 = Linux::Event::Timer->new(after => 0.5);
my $t3 = Linux::Event::Timer->new(every => 2.0);
# Integrate with event loop
my $fd = $t->fd;
my $fh = $t->fh;
my $rin = '';
vec($rin, $fd, 1) = 1;
select($rin, undef, undef, undef);
my $ticks = $t->read_ticks;
DESCRIPTION
This module provides a minimal, event-loop-neutral wrapper around Linux::FD::Timer (timerfd).
It does not perform any waiting internally and does not provide monotonic time helpers. Time math belongs in your scheduler layer.
CONSTRUCTOR
new
my $t = Linux::Event::Timer->new(%options);
Options:
nonblocking (bool, default 1)
cloexec (bool, default 1)
clock (string, default 'monotonic')
Clock id passed to
Linux::FD::Timer-new>. Typicallymonotonicorrealtime.timerfd (object)
Inject a pre-created timerfd-like object.
after => $seconds
Arm a one-shot timer immediately after construction.
every => $seconds
Arm a periodic timer immediately after construction.
Only one of
afteroreverymay be supplied.
METHODS
fd
Returns the numeric file descriptor.
fh
Returns a filehandle.
read_ticks
Drain the timerfd and return the number of expirations.
after($seconds)
Arm a one-shot timer.
every($interval)
Arm a periodic timer.
disarm
Disable the timer.
PLATFORM
Linux only.
AUTHOR
Joshua Day
LICENSE
Same terms as Perl itself.