Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

io::async::loop::epoll(3pm) [debian man page]

IO::Async::Loop::Epoll(3pm)				User Contributed Perl Documentation			       IO::Async::Loop::Epoll(3pm)

NAME
IO::Async::Loop::Epoll - use "IO::Async" with "epoll" on Linux SYNOPSIS
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/^(.*) ? // ) { print "You said: $1 "; } }, ) ); $loop->add( IO::Async::Signal->new( name => 'INT', on_receipt => sub { print "SIGINT, will now quit "; $loop->loop_stop; }, ) ); $loop->loop_forever(); DESCRIPTION
This subclass of IO::Async::Loop uses IO::Epoll to perform read-ready and write-ready tests so that the O(1) high-performance multiplexing of Linux's epoll_pwait(2) syscall can be used. The "epoll" Linux subsystem uses a registration system similar to the higher level IO::Poll object wrapper, meaning that better performance can be achieved in programs using a large number of filehandles. Each epoll_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 the epoll(7) manpage. This class uses the epoll_pwait(2) system call, which atomically switches the process's signal mask, performs a wait exactly as epoll_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
$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". $count = $loop->loop_once( $timeout ) This method calls the "poll()" method on the stored "IO::Epoll" object, passing in the value of $timeout, and processes the results of that call. It returns the total number of "IO::Async::Notifier" callbacks invoked, or "undef" if the underlying "epoll_pwait()" method returned an error. If the "epoll_pwait()" was interrupted by a signal, then 0 is returned instead. SEE ALSO
o IO::Epoll - Scalable IO Multiplexing for Linux 2.5.44 and higher o IO::Async::Loop::Poll - use IO::Async with poll(2) AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-04-10 IO::Async::Loop::Epoll(3pm)

Check Out this Related Man Page

IO::Async::Routine(3pm) 				User Contributed Perl Documentation				   IO::Async::Routine(3pm)

NAME
"IO::Async::Routine" - execute code in an independent sub-process SYNOPSIS
use IO::Async::Routine; use IO::Async::Channel; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $nums_ch = IO::Async::Channel->new; my $ret_ch = IO::Async::Channel->new; my $routine = IO::Async::Routine->new( channels_in => [ $nums_ch ], channels_out => [ $ret_ch ], code => sub { my @nums = @{ $nums_ch->recv }; my $ret = 0; $ret += $_ for @nums; # Can only send references $ret_ch->send( $ret ); }, on_finish => sub { say "The routine aborted early - $_[-1]"; $loop->stop; }, ); $loop->add( $routine ); $nums_ch->send( [ 10, 20, 30 ] ); $ret_ch->recv( on_recv => sub { my ( $ch, $totalref ) = @_; say "The total of 10, 20, 30 is: $$totalref"; $loop->stop; } ); $loop->run; DESCRIPTION
This subclass of IO::Async::Process contains a body of code and executes it in a sub-process, allowing it to act independently of the main program. Once set up, all communication with the code happens by values passed into or out of the Routine via IO::Async::Channel objects. Because the code running inside the Routine runs within its own process, it is isolated from the rest of the program, in terms of memory, CPU time, and other resources, and perhaps most importantly in terms of control flow. The code contained within the Routine is free to make blocking calls without stalling the rest of the program. This makes it useful for using existing code which has no option not to block within an "IO::Async"-based program. To create asynchronous wrappers of functions that return a value based only on their arguments, and do not generally maintain state within the process it may be more convenient to use an IO::Async::Function instead, which uses an "IO::Async::Routine" to contain the body of the function and manages the Channels itself. PARAMETERS
The following named parameters may be passed to "new" or "configure": channels_in => ARRAY of IO::Async::Channel ARRAY reference of "IO::Async::Channel" objects to set up for passing values in to the Routine. channels_out => ARRAY of IO::Async::Channel ARRAY reference of "IO::Async::Channel" objects to set up for passing values out of the Routine. code => CODE CODE reference to the body of the Routine, to execute once the channels are set up. METHODS
This class provides no additional methods, other than those provided by IO::Async::Process. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Routine(3pm)
Man Page