Linux::Perl::timerfd
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();
This is an interface to the timerfd_* family of system calls.
timerfd_*
This class inherits from Linux::Perl::Base::TimerEventFD.
%OPTS is:
clockid - One of: REALTIME, MONOTONIC, BOOTTIME, REALTIME_ALARM, or BOOTTIME_ALARM. Not all kernel versions support all of these; check man 2 timerfd_create for your system.
clockid
REALTIME
MONOTONIC
BOOTTIME
REALTIME_ALARM
BOOTTIME_ALARM
man 2 timerfd_create
flags - Optional, an array reference of any or all of: NONBLOCK, CLOEXEC.
flags
NONBLOCK
CLOEXEC
This follows the same practice as Linux::Perl::eventfd regarding CLOEXEC and $^F.
$^F
See man 2 timerfd_settime for details about what this does.
man 2 timerfd_settime
value - in seconds.
value
interval - in seconds. Must be falsy if value is falsy. (Rationale: timerfd_settime will ignore interval if value is zero. This seems unintuitive, so we avoid that situation altogether.)
interval
timerfd_settime
flags - Optional, arrayref. Accepted values are ABSTIME and CANCEL_ON_SET. Your kernel may not support all of these; check man 2 timerfd_settime for details.
ABSTIME
CANCEL_ON_SET
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.
Returns the old interval and value, in seconds.
See man 2 timerfd_create (look for TFD_IOC_SET_TICKS) for details on what this does.
TFD_IOC_SET_TICKS
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.)
See man 2 timerfd_create for details on what this returns. Sets $! and returns undef on error.
$!
To install Linux::Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Perl
CPAN shell
perl -MCPAN -e shell install Linux::Perl
For more information on module installation, please visit the detailed CPAN module installation guide.