Linux::Perl::eventfd
my $efd = Linux::Perl::eventfd->new( initval => 4, flags => [ 'NONBLOCK', 'CLOEXEC' ], #only on 2.6.27+ ); #or, e.g., Linux::Perl::eventfd::x86_64 my $fd = $efd->fileno(); $efd->add(12); my $read = $efd->read();
This is an interface to the eventfd/eventfd2 system call. (eventfd2 is only called if the given parameters require it.)
eventfd
eventfd2
This class inherits from Linux::Perl::Base::TimerEventFD.
%OPTS is:
initval - Optional, as described in the eventfd documentation. Defaults to 0.
initval
flags - Optional, an array reference of any or all of: NONBLOCK, CLOEXEC, SEMAPHORE. See man 2 eventfd for more details.
flags
NONBLOCK
CLOEXEC
SEMAPHORE
man 2 eventfd
Note that, in conformity with Perl convention, this module honors the $^F variable, which in its default configuration causes CLOEXEC even if the flag is not given. To have a non-CLOEXEC eventfd instance, then, set $^F to a high enough value that the eventfd file descriptor will not be an “OS” filehandle, e.g.:
my $eventfd = do { local $^F = 1000; Linux::Perl::eventfd->new(); };
Reads a value from the eventfd instance. Sets $! and returns undef on error.
$!
Adds NUMBER to the counter. Returns undef and sets $! on failure.
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.