The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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.

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. See man 2 eventfd for more details.

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.