1Select(3)             User Contributed Perl Documentation            Select(3)
2
3
4

NAME

6       Coro::Select - a (slow but coro-aware) replacement for CORE::select
7

SYNOPSIS

9        use Coro::Select;          # replace select globally (be careful, see below)
10        use Core::Select 'select'; # only in this module
11        use Coro::Select ();       # use Coro::Select::select
12

DESCRIPTION

14       This module tries to create a fully working replacement for perl's
15       "select" built-in, using "AnyEvent" watchers to do the job, so other
16       threads can run in parallel to any select user. As many libraries that
17       only have a blocking API do not use global variables and often use
18       select (or IO::Select), this effectively makes most such libraries
19       "somewhat" non-blocking w.r.t. other threads.
20
21       This implementation works fastest when only very few bits are set in
22       the fd set(s).
23
24       To be effective globally, this module must be "use"'d before any other
25       module that uses "select", so it should generally be the first module
26       "use"'d in the main program. Note that overriding "select" globally
27       might actually cause problems, as some "AnyEvent" backends use "select"
28       themselves, and asking AnyEvent to use Coro::Select, which in turn asks
29       AnyEvent will not quite work.
30
31       You can also invoke it from the commandline as "perl -MCoro::Select".
32
33       To override select only for a single module (e.g.
34       "Net::DBus::Reactor"), use a code fragment like this to load it:
35
36          {
37             package Net::DBus::Reactor;
38             use Coro::Select qw(select);
39             use Net::DBus::Reactor;
40          }
41
42       Some modules (notably POE::Loop::Select) directly call "CORE::select".
43       For these modules, we need to patch the opcode table by sandwiching it
44       between calls to "Coro::Select::patch_pp_sselect" and
45       "Coro::Select::unpatch_pp_sselect":
46
47        BEGIN {
48           use Coro::Select ();
49           Coro::Select::patch_pp_sselect;
50           require evil_poe_module_using_CORE::SELECT;
51           Coro::Select::unpatch_pp_sselect;
52        }
53

BUGS

55       For performance reasons, Coro::Select's select function might not
56       properly detect bad file descriptors (but relying on EBADF is
57       inherently non-portable).
58

SEE ALSO

60       Coro::LWP.
61

AUTHOR/SUPPORT/CONTACT

63          Marc A. Lehmann <schmorp@schmorp.de>
64          http://software.schmorp.de/pkg/Coro.html
65
66
67
68perl v5.28.0                      2017-08-31                         Select(3)
Impressum