NAME
Linux::Perl::epoll
SYNOPSIS
my $epl = Linux::Perl::epoll->new();
$epl->add( $fh, events => ['IN', 'ET'] );
my @events = $epl->wait(
maxevents => 3,
timeout => 2, #seconds
sigmask => ['INT', 'TERM'], #optional
);
$epl->delete($fh);
DESCRIPTION
An thin interface on top of Linuxýs
OBJ->add( $FD_OR_FH, %OPTS )
Adds a listener to the epoll instance. $FD_OR_FH is either a Perl filehandle or a file descriptor number. %OPTS are:
events
- An array reference of events/switches. The recognized event names are:IN
,OUT
,RDHUP
,PRI
,ERR
,HUP
,ET
,ONESHOT
,WAKEUP
, andEXCLUSIVE
. Your kernel may not support all of those; checkman 2 epoll_ctl
for details.data
- Optional, an arbitrary number to store with the file descriptor. This defaults to the file descriptor.
OBJ->modify( $FD_OR_FH, %OPTS )
Same arguments as add()
.
OBJ->delete( $FD_OR_FH )
Same arguments as add()
.
@events = OBJ->wait( %OPTS )
Waits for one or more events on the epoll. %OPTS are:
maxevents
- The number of events to listen for.timeout
- in secondssigmask
- Optional, an array of signals to block. The signals can be specified either as names (e.g.,INT
) or as numbers. Seeman 2 epoll_pwait
for why you might want to do this. (Note that Perl doesnýt really expect you to do signal blocking, so this may screw up in weird ways. If in doubt, avoid this option.)
The return is a list of hash references, one for each received event. Each hash reference is:
data
- The same number given inadd()
.events
- Corresponds to the same-named array given inadd()
, but to optimize performance this is returned as a single number. Check for specific events by iterating through theEVENT_NUMBER()
hash reference.
Each hash reference has events
and data
., analogous to the same inputs as given to add()
above.