Leon Timmermans > Linux-Epoll-0.010 > Linux::Epoll

Download:
Linux-Epoll-0.010.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.010   Source   Latest Release: Linux-Epoll-0.011

NAME ^

Linux::Epoll - O(1) multiplexing for Linux

VERSION ^

version 0.010

SYNOPSIS ^

 use Linux::Epoll;

 my $epoll = Linux::Epoll->new();
 $epoll->add($fh, 'in', sub {
     my $events = shift;
     do_something($fh) if $events->{in};
 });
 $epoll->wait while 1;

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

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; if the file can't be waited upon it sets $! to EPERM instead. On all other error conditions an exception is thrown. The callback gets a single argument, a hashref whose keys are the triggered events.

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. If interrupted by a signal it returns undef/an empty list and sets $! to EINTR. On all other error conditions an exception is thrown.

SEE ALSO ^

AUTHOR ^

Leon Timmermans <leont@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2010 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: