NAME
Linux::Epoll - O(1) multiplexing for Linux
VERSION
Version 0.002
SYNOPSIS
use Linux::Epoll;
my $epoll = Linux::Epoll->new();
$epoll->add($fh, 'in', sub { do_something($fh) });
1 while $epoll->wait;
DESCRIPTION
Epoll is a multiplexing mechanism that scales up O(1) with number of watched files. Linux::Epoll is a callback style epoll module, unlike other epoll modules available on CPAN.
Types of events
in
The associated filehandle is availible for reading.
out
The associated filehandle is availible for writing.
err
An error condition has happened on the associated filehandle.
waitwill always wait on this event, it is not necessary to set this withaddormodify.prio
There is urgent data available for reading.
et
Set edge triggered behavior for the associated filehandle. The default behavior is level triggered. See you epoll(7) documentation for more information on what this means.
hup
A hang-up has happened on the associated filehandle.
waitwill always wait on this event, it is not necessary to set this withaddormodify.rdhup
Stream socket peer closed the connection, or shut down the writing half of connection. This flag is especially useful for writing simple code to detect peer shutdown when using Edge Triggered monitoring.
oneshot
Sets the one-shot behavior for the associated file descriptor. This means that after an event is pulled out with
waitthe associated file descriptor is internally disabled and no other events will be reported by the epoll interface. The user must callmodifyto rearm the file descriptor with a new event mask.
METHODS
new()
Create a new epoll instance.
add($fh, $events, $callback)
Register the filehandle with the epoll instance and associate events $events and callback $callback with it. $events may be either a string (e.g. 'in') or an arrayref (e.g. [qw/in out hup/]). If a filehandle already exists in the set and add is called in non-void context, it returns undef and sets $! to EEXIST. On all other error conditions an exception is thrown.
modify($fh, $events, $callback)
Change the events and callback associated on this epoll instance with filehandle $fh. The arguments work the same as with add. If a filehandle doesn't exist in the set and modify is called in non-void context, it returns undef and sets $! to ENOENT. On all other error conditions an exception is thrown.
delete($fh)
Remove a filehandle from the epoll instance. If a filehandle doesn't exist in the set and delete is called in non-void context, it returns undef and sets $! to ENOENT. On all other error conditions an exception is thrown.
wait($number = 1, $timeout = undef, $sigmask = undef)
Wait for up to $number events, where $number must be greater than zero. $timeout is the maximal time wait will wait for events in fractional seconds. If it is undefined it may wait indefinitely. $sigmask is the signal mask during the call. If it is not defined the signal mask will be untouched.
SEE ALSO
AUTHOR
Leon Timmermans, <leont at cpan.org>
BUGS
Please report any bugs or feature requests to bug-linux-epoll at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-Epoll. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Linux::Epoll
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2010 Leon Timmermans.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.