NAME
Linux::Perl::eventfd
SYNOPSIS
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();
DESCRIPTION
This is an interface to the eventfd
/eventfd2
system call. (eventfd2
is only called if the given parameters require it.)
METHODS
CLASS->new( %OPTS )
%OPTS is:
initval
- Optional, as described in the eventfd documentation. Defaults to 0.flags
- Optional, an array reference of any or all of:NONBLOCK
,CLOEXEC
,SEMAPHORE
. Seeman 2 eventfd
for more details.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(); };
OBJ->fileno()
Returns the file descriptor number.
$val = OBJ->read()
Reads a value from the eventfd instance. Sets $!
and returns undef on error.
OBJ->add( NUMBER )
Adds NUMBER to the counter.