NAME
Linux::Perl::timerfd
SYNOPSIS
my $tfd = Linux::Perl::timerfd->new(
clockid => 'REALTIME',
flags => [ 'NONBLOCK', 'CLOEXEC' ],
);
#or, e.g., Linux::Perl::timerfd::x86_64
my $fd = $tfd->fileno();
($old_interval, $old_value) = $tfd->settime(
interval => $interval_seconds,
value => $value_seconds,
flags => [ 'ABSTIME', 'CANCEL_ON_SET' ],
);
my ($interval, $value) = $tfd->gettime();
$tfd->set_ticks(12);
my $read = $tfd->read();
DESCRIPTION
This is an interface to the timerfd_* family of system calls.
This class inherits from Linux::Perl::Base::TimerEventFD.
METHODS
CLASS->new( %OPTS )
%OPTS is:
clockid- One of:REALTIME,MONOTONIC,BOOTTIME,REALTIME_ALARM, orBOOTTIME_ALARM. Not all kernel versions support all of these; checkman 2 timerfd_createfor your system.flags- Optional, an array reference of any or all of:NONBLOCK,CLOEXEC.This follows the same practice as Linux::Perl::eventfd regarding CLOEXEC and
$^F.
$OBJ = OBJ->settime( %OPTS )
($old_interval, $old_value) = OBJ->settime( %OPTS )
See man 2 timerfd_settime for details about what this does.
%OPTS is:
value- in seconds.interval- in seconds. Must be falsy ifvalueis falsy. (Rationale:timerfd_settimewill ignoreintervalifvalueis zero. This seems unintuitive, so we avoid that situation altogether.)flags- Optional, arrayref. Accepted values areABSTIMEandCANCEL_ON_SET. Your kernel may not support all of these; checkman 2 timerfd_settimefor details.
In scalar context this returns the object. This facilitates easy setting of the value on instantiation.
In list context it returns the previous interval and value.
($old_interval, $old_value) = OBJ->gettime()
Returns the old interval and value, in seconds.
my $ok_yn = OBJ->set_ticks( $NUM_TICKS )
See man 2 timerfd_create (look for TFD_IOC_SET_TICKS) for details on what this does.
This returns truthy if the operation succeeded and falsy if the system does not support this operation. (Any other failure will prompt an exception to be thrown.)
$expirations = OBJ->read()
See man 2 timerfd_create for details on what this returns. Sets $! and returns undef on error.