ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/EV/EV.pm
(Generate patch)

Comparing Coro/EV/EV.pm (file contents):
Revision 1.89 by root, Sat Jul 11 01:59:05 2015 UTC vs.
Revision 1.90 by root, Sun Oct 4 13:07:56 2015 UTC

8 use Coro::EV; 8 use Coro::EV;
9 9
10 EV::READ & Coro::EV::timed_io_once $fh, EV::READ, 60 10 EV::READ & Coro::EV::timed_io_once $fh, EV::READ, 60
11 or die "timeout\n"; 11 or die "timeout\n";
12 12
13 EV::loop; 13 EV::run;
14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17This module does two things: First, it offers some utility functions that 17This module does two things: First, it offers some utility functions that
18might be useful for threads (although L<Coro::AnyEvent> offers more and 18might be useful for threads (although L<Coro::AnyEvent> offers more and
19more portable functions), and secondly, it integrates Coro into the EV 19more portable functions), and secondly, it integrates Coro into the EV
20main loop: 20main loop:
21 21
22Before the process blocks (in EV::loop) to wait for events, this module 22Before the process blocks (in EV::run) to wait for events, this module
23will schedule and run all ready (= runnable) threads of the same or 23will schedule and run all ready (= runnable) threads of the same or
24higher priority. After that, it will cede once to a threads of lower 24higher priority. After that, it will cede once to a threads of lower
25priority, then continue in the event loop. 25priority, then continue in the event loop.
26 26
27That means that threads with the same or higher priority as the threads 27That means that threads with the same or higher priority as the threads
30processing. Note that for that to work you actually have to run the EV 30processing. Note that for that to work you actually have to run the EV
31event loop in some thread. 31event loop in some thread.
32 32
33=head1 RUNNING WITH OR WITHOUT A MAINLOOP 33=head1 RUNNING WITH OR WITHOUT A MAINLOOP
34 34
35In general, you should always run EV::loop, either in your main program, 35In general, you should always run EV::run, either in your main program,
36or in a separate coroutine. If you don't do that and all coroutines 36or in a separate coroutine. If you don't do that and all coroutines
37start waiting for some events, this module will run the event loop once, 37start waiting for some events, this module will run the event loop once,
38but this is very inefficient and will also not make it possible to run 38but this is very inefficient and will also not make it possible to run
39background threads. 39background threads.
40 40
41To run the EV event loop in a separate thread, you can simply do this: 41To run the EV event loop in a separate thread, you can simply do this:
42 42
43 async { EV::loop }; 43 async { EV::run };
44 44
45=head1 FUNCTIONS 45=head1 FUNCTIONS
46 46
47=over 4 47=over 4
48 48

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines