NAME

Linux::Event::Backend::Epoll - Epoll backend for Linux::Event::Loop (via Linux::Epoll)

SYNOPSIS

use v5.36;
use Linux::Event::Backend::Epoll;

my $be = Linux::Event::Backend::Epoll->new;

my $fd = $be->watch($fh, $mask, sub ($loop, $fh, $fd, $mask, $tag) {
  ...
}, _loop => $loop, tag => $tag);

$be->modify($fh, $new_mask, _loop => $loop);

$be->unwatch($fh);

DESCRIPTION

Thin adapter over Linux::Epoll used as the mechanism layer for Linux::Event::Loop.

The backend is responsible for:

  • Registering filehandles with epoll

  • Waiting for readiness

  • Converting Linux::Epoll events into an integer mask

  • Dispatching to the callback contract expected by the loop

STATUS

EXPERIMENTAL / WORK IN PROGRESS

The API is not yet considered stable and may change without notice.

METHODS

new(%args)

Optional args:

  • edge - if true, defaults registrations to edge-triggered

  • oneshot - if true, defaults registrations to one-shot

watch($fh, $mask, $cb, %opt) -> $fd

Register a filehandle. $cb is invoked as:

$cb->($loop, $fh, $fd, $mask, $tag)

Options:

  • _loop - loop reference passed through to callback

  • tag - arbitrary user value passed through to callback

modify($fh_or_fd, $mask, %opt) -> $bool

Update the epoll interest set for an already-watched file descriptor.

Uses Linux::Epoll-modify> if available, otherwise falls back to a safe delete+add re-registration.

unwatch($fh_or_fd) -> $bool

Unregister a file descriptor or filehandle.

run_once($loop, $timeout_s=undef)

Perform one epoll wait/dispatch cycle.

SEE ALSO

Linux::Event, Linux::Event::Loop, Linux::Epoll