++ed by:
ETHER FARACO TSIBLEY PINGAN POTATOGIM

28 PAUSE users
26 non-PAUSE users.

Paul Evans
and 1 contributors

NAME

IO::Async::Set::IO_Poll - a class that maintains a set of IO::Async::Notifier objects by using an IO::Poll object.

SYNOPSIS

 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();
    ...
 }

Or

 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();
 }

DESCRIPTION

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.

CONSTRUCTOR

$set = IO::Async::Set::IO_Poll->new( %args )

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.

METHODS

$set->post_poll( $poll )

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.

$poll

Reference to the IO::Poll object

$ready = $set->loop_once( $timeout )

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.

$set->loop_forever()

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.

$set->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.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>