-
-
27 May 2021 20:27:06 UTC
- Distribution: IO-Async-Loop-Epoll
- Module version: 0.22
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (49 / 0 / 0)
- Kwalitee
Bus factor: 1- 87.71% Coverage
- License: perl_5
- Perl: v5.14.0
- Activity
24 month- Tools
- Download (16.23KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- IO::Async
- Linux::Epoll
- Struct::Dumb
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
IO::Async::Loop::Epoll
- useIO::Async
withepoll
on LinuxSYNOPSIS
use IO::Async::Loop::Epoll; use IO::Async::Stream; use IO::Async::Signal; my $loop = IO::Async::Loop::Epoll->new; $loop->add( IO::Async::Stream->new( read_handle => \*STDIN, on_read => sub { my ( $self, $buffref ) = @_; while( $$buffref =~ s/^(.*)\r?\n// ) { print "You said: $1\n"; } }, ) ); $loop->add( IO::Async::Signal->new( name => 'INT', on_receipt => sub { print "SIGINT, will now quit\n"; $loop->stop; }, ) ); $loop->run;
DESCRIPTION
This subclass of IO::Async::Loop uses
epoll(7)
on Linux to perform read-ready and write-ready tests so that the O(1) high-performance multiplexing of Linux'sepoll_pwait(2)
syscall can be used.The
epoll
Linux subsystem uses a persistent registration system, meaning that better performance can be achieved in programs using a large number of filehandles. Eachepoll_pwait(2)
syscall only has an overhead proportional to the number of ready filehandles, rather than the total number being watched. For more detail, see theepoll(7)
manpage.This class uses the
epoll_pwait(2)
system call, which atomically switches the process's signal mask, performs a wait exactly asepoll_wait(2)
would, then switches it back. This allows a process to block the signals it cares about, but switch in an empty signal mask during the poll, allowing it to handle file IO and signals concurrently.CONSTRUCTOR
new
$loop = IO::Async::Loop::Epoll->new()
This function returns a new instance of a
IO::Async::Loop::Epoll
object.METHODS
As this is a subclass of IO::Async::Loop, all of its methods are inherited. Expect where noted below, all of the class's methods behave identically to
IO::Async::Loop
.loop_once
$count = $loop->loop_once( $timeout )
This method calls
epoll_pwait(2)
, and processes the results of that call. It returns the total number ofIO::Async::Notifier
callbacks invoked, orundef
if the underlyingepoll_pwait()
method returned an error. If theepoll_pwait()
was interrupted by a signal, then 0 is returned instead.SEE ALSO
Linux::Epoll - O(1) multiplexing for Linux
IO::Async::Loop::Poll - use IO::Async with poll(2)
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
Module Install Instructions
To install IO::Async::Loop::Epoll, copy and paste the appropriate command in to your terminal.
cpanm IO::Async::Loop::Epoll
perl -MCPAN -e shell install IO::Async::Loop::Epoll
For more information on module installation, please visit the detailed CPAN module installation guide.