1EV(3) User Contributed Perl Documentation EV(3)
2
3
4
6 Coro::EV - do events the coro-way, with EV
7
9 use Coro;
10 use Coro::EV;
11
12 EV::READ & Coro::EV::timed_io_once $fh, EV::READ, 60
13 or die "timeout\n";
14
15 EV::run;
16
18 This module does two things: First, it offers some utility functions
19 that might be useful for threads (although Coro::AnyEvent offers more
20 and more portable functions), and secondly, it integrates Coro into the
21 EV main loop:
22
23 Before the process blocks (in EV::run) to wait for events, this module
24 will schedule and run all ready (= runnable) threads of the same or
25 higher priority. After that, it will cede once to a threads of lower
26 priority, then continue in the event loop.
27
28 That means that threads with the same or higher priority as the threads
29 running the main loop will inhibit event processing, while threads of
30 lower priority will get the CPU, but cannot completeley inhibit event
31 processing. Note that for that to work you actually have to run the EV
32 event loop in some thread.
33
35 In general, you should always run EV::run, either in your main program,
36 or in a separate coroutine. If you don't do that and all coroutines
37 start waiting for some events, this module will run the event loop
38 once, but this is very inefficient and will also not make it possible
39 to run background threads.
40
41 To run the EV event loop in a separate thread, you can simply do this:
42
43 async { EV::run };
44
46 $revents = Coro::EV::timed_io_once $fileno_or_fh, $events[, $timeout]
47 Blocks the coroutine until either the given event set has occurred
48 on the fd, or the timeout has been reached (if timeout is missing
49 or "undef" then there will be no timeout). Returns the received
50 flags.
51
52 Consider using "Coro::AnyEvent::readable" and
53 "Coro::AnyEvent::writable" instead, they work with any AnyEvent-
54 supported event loop.
55
56 Coro::EV::timer_once $after
57 Blocks the coroutine for at least $after seconds.
58
59 Consider using "Coro::AnyEvent::sleep" instead, which works with
60 any AnyEvent-supported event loop.
61
63 Marc A. Lehmann <schmorp@schmorp.de>
64 http://software.schmorp.de/pkg/Coro.html
65
66
67
68perl v5.34.0 2021-07-22 EV(3)