1IO::Async::Loop::SelectU(s3e)r Contributed Perl DocumentaItOi:o:nAsync::Loop::Select(3)
2
3
4

NAME

6       "IO::Async::Loop::Select" - use "IO::Async" with "select(2)"
7

SYNOPSIS

9        use IO::Async::Loop::Select;
10
11        my $loop = IO::Async::Loop::Select->new();
12
13        $loop->add( ... );
14
15        $loop->loop_forever();
16
17       Or
18
19        while(1) {
20           $loop->loop_once();
21           ...
22        }
23
24       Or
25
26        while(1) {
27           my ( $rvec, $wvec, $evec ) = ('') x 3;
28           my $timeout;
29
30           $loop->pre_select( \$rvec, \$wvec, \$evec, \$timeout );
31           ...
32           my $ret = select( $rvec, $wvec, $evec, $timeout );
33           ...
34           $loop->post_select( $rvec, $evec, $wvec );
35        }
36

DESCRIPTION

38       This subclass of "IO::Async::Loop" uses the "select()" syscall to
39       perform read-ready and write-ready tests.
40
41       To integrate with an existing "select()"-based event loop, a pair of
42       methods "pre_select()" and "post_select()" can be called immediately
43       before and after a "select()" call. The relevant bit in the read-ready
44       bitvector is always set by the "pre_select()" method, but the
45       corresponding bit in write-ready vector is set depending on the state
46       of the 'want_writeready' property. The "post_select()" method will
47       invoke the "on_read_ready()" or "on_write_ready()" methods or callbacks
48       as appropriate.
49

CONSTRUCTOR

51   $loop = IO::Async::Loop::Select->new()
52       This function returns a new instance of a "IO::Async::Loop::Select"
53       object.  It takes no special arguments.
54

METHODS

56   $loop->pre_select( \$readvec, \$writevec, \$exceptvec, \$timeout )
57       This method prepares the bitvectors for a "select()" call, setting the
58       bits that notifiers registered by this loop are interested in. It will
59       always set the appropriate bits in the read vector, but will only set
60       them in the write vector if the notifier's "want_writeready()" property
61       is true. Neither the exception vector nor the timeout are affected.
62
63       \$readvec
64       \$writevec
65       \$exceptvec
66               Scalar references to the reading, writing and exception
67               bitvectors
68
69       \$timeout
70               Scalar reference to the timeout value
71
72   $loop->post_select( $readvec, $writevec, $exceptvec )
73       This method checks the returned bitvectors from a "select()" call, and
74       calls any of the notification methods or callbacks that are
75       appropriate.
76
77       $readvec
78       $writevec
79       $exceptvec
80               Scalars containing the read-ready, write-ready and exception
81               bitvectors
82
83   $count = $loop->loop_once( $timeout )
84       This method calls the "pre_select()" method to prepare the bitvectors
85       for a "select()" syscall, performs it, then calls "post_select()" to
86       process the result. It returns the total number of callbacks invoked by
87       the "post_select()" method, or "undef" if the underlying "select()"
88       syscall returned an error.
89

SEE ALSO

91       ยท   IO::Select - OO interface to select system call
92

AUTHOR

94       Paul Evans <leonerd@leonerd.org.uk>
95
96
97
98perl v5.12.1                      2010-06-09        IO::Async::Loop::Select(3)
Impressum