1IO::Async::Loop::Poll(3U)ser Contributed Perl DocumentatiIoOn::Async::Loop::Poll(3)
2
3
4

NAME

6       "IO::Async::Loop::Poll" - use "IO::Async" with "poll(2)"
7

SYNOPSIS

9       Normally an instance of this class would not be directly constructed by
10       a program. It may however, be useful for runinng IO::Async with an
11       existing program already using an "IO::Poll" object.
12
13        use IO::Poll;
14        use IO::Async::Loop::Poll;
15
16        my $poll = IO::Poll->new;
17        my $loop = IO::Async::Loop::Poll->new( poll => $poll );
18
19        $loop->add( ... );
20
21        while(1) {
22           my $timeout = ...
23           my $ret = $poll->poll( $timeout );
24           $loop->post_poll;
25        }
26

DESCRIPTION

28       This subclass of IO::Async::Loop uses the poll(2) system call to
29       perform read-ready and write-ready tests.
30
31       By default, this loop will use the underlying "poll()" system call
32       directly, bypassing the usual IO::Poll object wrapper around it because
33       of a number of bugs and design flaws in that class; namely
34
35       · <https://rt.cpan.org/Ticket/Display.html?id=93107> - IO::Poll relies
36         on stable stringification of IO handles
37
38       · <https://rt.cpan.org/Ticket/Display.html?id=25049> - IO::Poll->poll()
39         with no handles always returns immediately
40
41       However, to integrate with existing code that uses an "IO::Poll"
42       object, a "post_poll" can be called immediately after the "poll" method
43       that "IO::Poll" object. The appropriate mask bits are maintained on the
44       "IO::Poll" object when notifiers are added or removed from the loop, or
45       when they change their "want_*" status. The "post_poll" method inspects
46       the result bits and invokes the "on_read_ready" or "on_write_ready"
47       methods on the notifiers.
48

CONSTRUCTOR

50   new
51          $loop = IO::Async::Loop::Poll->new( %args )
52
53       This function returns a new instance of a "IO::Async::Loop::Poll"
54       object. It takes the following named arguments:
55
56       "poll"  The "IO::Poll" object to use for notification. Optional; if a
57               value is not given, the underlying "IO::Poll::_poll()" function
58               is invoked directly, outside of the object wrapping.
59

METHODS

61   post_poll
62          $count = $loop->post_poll
63
64       This method checks the returned event list from a "IO::Poll::poll"
65       call, and calls any of the notification methods or callbacks that are
66       appropriate.  It returns the total number of callbacks that were
67       invoked; that is, the total number of "on_read_ready" and
68       "on_write_ready" callbacks for "watch_io", and "watch_time" event
69       callbacks.
70
71   loop_once
72          $count = $loop->loop_once( $timeout )
73
74       This method calls the "poll" method on the stored "IO::Poll" object,
75       passing in the value of $timeout, and then runs the "post_poll" method
76       on itself. It returns the total number of callbacks invoked by the
77       "post_poll" method, or "undef" if the underlying "poll" method returned
78       an error.
79

AUTHOR

81       Paul Evans <leonerd@leonerd.org.uk>
82
83
84
85perl v5.28.1                      2019-02-02          IO::Async::Loop::Poll(3)
Impressum