IO::Async::Set::IO_Poll - a class that maintains a set of IO::Async::Notifier objects by using an IO::Poll object.
IO::Async::Set::IO_Poll
IO::Async::Notifier
IO::Poll
use IO::Async::Set::IO_Poll; my $set = IO::Async::Set::IO_Poll->new(); $set->add( ... ); $set->loop_forever();
Or
while(1) { $set->loop_once(); ... }
use IO::Poll; use IO::Async::Set::IO_Poll; my $poll = IO::Poll->new(); my $set = IO::Async::Set::IO_Poll->new( poll => $poll ); $set->add( ... ); while(1) { my $timeout = ... my $ret = $poll->poll( $timeout ); $set->post_poll(); }
This subclass of IO::Async::Notifier uses an IO::Poll object to perform read-ready and write-ready tests.
To integrate with existing code that uses an IO::Poll, a post_poll() can be called immediately after the poll() method on the contained IO::Poll object. The appropriate mask bits are maintained on the IO::Poll object when notifiers are added or removed from the set, or when they change their want_writeready status. The post_poll() method inspects the result bits and invokes the on_read_ready() or on_write_ready() methods on the notifiers.
post_poll()
poll()
want_writeready
on_read_ready()
on_write_ready()
This function returns a new instance of a IO::Async::Set::IO_Poll object. It takes the following named arguments:
poll
The IO::Poll object to use for notification. Optional; if a value is not given, a new IO::Poll will be constructed.
This method checks the returned event list from a IO::Poll::poll() call, and calls any of the notification methods or callbacks that are appropriate.
IO::Poll::poll()
Reference to the IO::Poll object
This method calls the poll() method on the stored IO::Poll object, passing in the value of $timeout, and then runs the post_poll() method on itself. It returns the value returned by the underlying poll() method; which will be the number of handles that returned a result, 0 if a timeout occured, or undef on error.
$timeout
undef
This method repeatedly calls the loop_once method with no timeout (i.e. allowing the poll() method to block indefinitely), until the loop_stop method is called from an event callback.
loop_once
loop_stop
This method cancels a running loop_forever, and makes that method return. It would be called from an event callback triggered by an event that occured within the loop.
loop_forever
Paul Evans <leonerd@leonerd.org.uk>
To install IO::Async::Set, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Async::Set
CPAN shell
perl -MCPAN -e shell install IO::Async::Set
For more information on module installation, please visit the detailed CPAN module installation guide.