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

AnyEvent::Impl::IOAsync(3pm)				User Contributed Perl Documentation			      AnyEvent::Impl::IOAsync(3pm)

NAME
AnyEvent::Impl::IOAsync - AnyEvent adaptor for IO::Async SYNOPSIS
use AnyEvent; use IO::Async::Loop; # optionally set another event loop use AnyEvent::Impl::IOAsync; my $loop = new IO::Async::Loop; AnyEvent::Impl::IOAsync::set_loop $loop; DESCRIPTION
This module provides support for IO::Async as AnyEvent backend. It supports I/O, timers, signals and child process watchers. Idle watchers are emulated. I/O watchers need to dup their fh because IO::Async only supports IO handles, not plain file descriptors. PROBLEMS WITH IO
::Async This section had a long list of problems and shortcomings that made it almost impossible to support IO::Async. With version 0.33 of IO::Async, however, most of these have been fixed, so IO::Async can now be used as easily as many other loops. There are a few remaining problems that require emulation or workarounds: No support for multiple watchers per event In most (all? documentation?) cases you cannot have multiple watchers for the same event (what's the point of having all these fancy notifier classes when you cannot have multiple notifiers for the same event? That's like only allowing one timer per second or so...). For I/O watchers, AnyEvent has to dup() every file handle, as IO::Async fails to support the same or different file handles pointing to the same fd (the good thing is that it is documented, but why not fix it instead?). Apart from these fatal flaws, there are a number of unpleasent properties that just need some mentioning: Confusing and misleading names Another rather negative point about this module family is its name, which is deeply confusing: Despite the "async" in the name, IO::Async only does synchronous I/O, there is nothing "asynchronous" about it whatsoever (when I first heard about it, I thought, "wow, a second async I/O module, what does it do compared to IO::AIO", and was somehow set back when I learned that the only "async" aspect of it is the name). Inconsistent, incomplete and convoluted API Implementing AnyEvent's rather simple timers on top of IO::Async's timers was a nightmare (try implementing a timer with configurable interval and delay value...). The method naming is chaotic: "watch_child" creates a child watcher, but "watch_io" is an internal method; "detach_signal" removes a signal watcher, but "detach_child" forks a subprocess and so on). Unpleasant surprises on GNU/Linux When you develop your program on FreeBSD and run it on GNU/Linux, you might have unpleasant surprises, as IO::Async::Loop will by default use IO::Async::Loop::Epoll, which is incompatible with "fork", so your network server will run into spurious and very hard to debug problems under heavy load, as IO::Async forks a lot of processes, e.g. for DNS resolution. It would be better if IO::Async would only load "safe" backends by default (or fix the epoll backend to work in the presence of fork, which admittedly is hard - EV does it for you, and also does not use unsafe backends by default). On the positive side, performance with IO::Async is quite good even in my very demanding eyes. SEE ALSO
AnyEvent, IO::Async. AUTHOR
Marc Lehmann <schmorp@schmorp.de> http://anyevent.schmorp.de Paul Evans <leonerd@leonerd.org.uk> Rewrote the backend for IO::Async version 0.33. perl v5.14.2 2012-04-08 AnyEvent::Impl::IOAsync(3pm)
Man Page