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       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 a "select" call.
12
13        use IO::Async::Loop::Select;
14
15        my $loop = IO::Async::Loop::Select->new;
16
17        $loop->add( ... );
18
19        while(1) {
20           my ( $rvec, $wvec, $evec ) = ('') x 3;
21           my $timeout;
22
23           $loop->pre_select( \$rvec, \$wvec, \$evec, \$timeout );
24           ...
25           my $ret = select( $rvec, $wvec, $evec, $timeout );
26           ...
27           $loop->post_select( $rvec, $evec, $wvec );
28        }
29

DESCRIPTION

31       This subclass of IO::Async::Loop uses the select(2) syscall to perform
32       read-ready and write-ready tests.
33
34       To integrate with an existing "select"-based event loop, a pair of
35       methods "pre_select" and "post_select" can be called immediately before
36       and after a "select" call. The relevant bits in the read-ready, write-
37       ready and exceptional-state bitvectors are set by the "pre_select"
38       method, and tested by the "post_select" method to pick which event
39       callbacks to invoke.
40

CONSTRUCTOR

42   new
43          $loop = IO::Async::Loop::Select->new
44
45       This function returns a new instance of a "IO::Async::Loop::Select"
46       object.  It takes no special arguments.
47

METHODS

49   pre_select
50          $loop->pre_select( \$readvec, \$writevec, \$exceptvec, \$timeout )
51
52       This method prepares the bitvectors for a "select" call, setting the
53       bits that the Loop is interested in. It will also adjust the $timeout
54       value if appropriate, reducing it if the next event timeout the Loop
55       requires is sooner than the current value.
56
57       \$readvec
58       \$writevec
59       \$exceptvec
60               Scalar references to the reading, writing and exception
61               bitvectors
62
63       \$timeout
64               Scalar reference to the timeout value
65
66   post_select
67          $loop->post_select( $readvec, $writevec, $exceptvec )
68
69       This method checks the returned bitvectors from a "select" call, and
70       calls any of the callbacks that are appropriate.
71
72       $readvec
73       $writevec
74       $exceptvec
75               Scalars containing the read-ready, write-ready and exception
76               bitvectors
77
78   loop_once
79          $count = $loop->loop_once( $timeout )
80
81       This method calls the "pre_select" method to prepare the bitvectors for
82       a "select" syscall, performs it, then calls "post_select" to process
83       the result. It returns the total number of callbacks invoked by the
84       "post_select" method, or "undef" if the underlying select(2) syscall
85       returned an error.
86

SEE ALSO

88       ยท   IO::Select - OO interface to select system call
89

AUTHOR

91       Paul Evans <leonerd@leonerd.org.uk>
92
93
94
95perl v5.32.0                      2020-09-24        IO::Async::Loop::Select(3)
Impressum