… | |
… | |
54 | |
54 | |
55 | DESCRIPTION |
55 | DESCRIPTION |
56 | This module provides an interface to libev |
56 | This module provides an interface to libev |
57 | (<http://software.schmorp.de/pkg/libev.html>). While the documentation |
57 | (<http://software.schmorp.de/pkg/libev.html>). While the documentation |
58 | below is comprehensive, one might also consult the documentation of |
58 | below is comprehensive, one might also consult the documentation of |
59 | libev itself (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod>) |
59 | libev itself (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod> or |
60 | for more subtle details on watcher semantics or some discussion on the |
60 | perldoc EV::libev) for more subtle details on watcher semantics or some |
61 | available backends, or how to force a specific backend with |
61 | discussion on the available backends, or how to force a specific backend |
62 | "LIBEV_FLAGS", or just about in any case because it has much more |
62 | with "LIBEV_FLAGS", or just about in any case because it has much more |
63 | detailed information. |
63 | detailed information. |
64 | |
64 | |
65 | This module is very fast and scalable. It is actually so fast that you |
65 | This module is very fast and scalable. It is actually so fast that you |
66 | can use it through the AnyEvent module, stay portable to other event |
66 | can use it through the AnyEvent module, stay portable to other event |
67 | loops (if you don't rely on any watcher types not available through it) |
67 | loops (if you don't rely on any watcher types not available through it) |
68 | and still be faster than with any other event loop currently supported |
68 | and still be faster than with any other event loop currently supported |
69 | in Perl. |
69 | in Perl. |
|
|
70 | |
|
|
71 | MODULE EXPORTS |
|
|
72 | This module does not export any symbols. |
70 | |
73 | |
71 | EVENT LOOPS |
74 | EVENT LOOPS |
72 | EV supports multiple event loops: There is a single "default event loop" |
75 | EV supports multiple event loops: There is a single "default event loop" |
73 | that can handle everything including signals and child watchers, and any |
76 | that can handle everything including signals and child watchers, and any |
74 | number of "dynamic event loops" that can use different backends (with |
77 | number of "dynamic event loops" that can use different backends (with |
… | |
… | |
92 | |
95 | |
93 | $loop = new EV::loop [$flags] |
96 | $loop = new EV::loop [$flags] |
94 | Create a new event loop as per the specified flags. Please refer to |
97 | Create a new event loop as per the specified flags. Please refer to |
95 | the "ev_loop_new ()" function description in the libev documentation |
98 | the "ev_loop_new ()" function description in the libev documentation |
96 | (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#GLOBAL_FUNCTI |
99 | (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#GLOBAL_FUNCTI |
97 | ONS>) for more info. |
100 | ONS>, or locally-installed as EV::libev manpage) for more info. |
98 | |
101 | |
99 | The loop will automatically be destroyed when it is no longer |
102 | The loop will automatically be destroyed when it is no longer |
100 | referenced by any watcher and the loop object goes out of scope. |
103 | referenced by any watcher and the loop object goes out of scope. |
101 | |
104 | |
102 | Using "EV::FLAG_FORKCHECK" is recommended, as only the default event |
105 | If you are not embedding the loop, then Using "EV::FLAG_FORKCHECK" |
103 | loop is protected by this module. |
106 | is recommended, as only the default event loop is protected by this |
|
|
107 | module. If you *are* embedding this loop in the default loop, this |
|
|
108 | is not necessary, as "EV::embed" automatically does the right thing |
|
|
109 | on fork. |
104 | |
110 | |
105 | $loop->loop_fork |
111 | $loop->loop_fork |
106 | Must be called after a fork in the child, before entering or |
112 | Must be called after a fork in the child, before entering or |
107 | continuing the event loop. An alternative is to use |
113 | continuing the event loop. An alternative is to use |
108 | "EV::FLAG_FORKCHECK" which calls this function automatically, at |
114 | "EV::FLAG_FORKCHECK" which calls this function automatically, at |
… | |
… | |
217 | $loop->set_timeout_collect_interval ($time) |
223 | $loop->set_timeout_collect_interval ($time) |
218 | These advanced functions set the minimum block interval when polling |
224 | These advanced functions set the minimum block interval when polling |
219 | for I/O events and the minimum wait interval for timer events. See |
225 | for I/O events and the minimum wait interval for timer events. See |
220 | the libev documentation at |
226 | the libev documentation at |
221 | <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONT |
227 | <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONT |
222 | ROLLING_THE_EVENT_LOOP> for a more detailed discussion. |
228 | ROLLING_THE_EVENT_LOOP> (locally installed as EV::libev) for a more |
|
|
229 | detailed discussion. |
223 | |
230 | |
224 | WATCHER OBJECTS |
231 | WATCHER OBJECTS |
225 | A watcher is an object that gets created to record your interest in some |
232 | A watcher is an object that gets created to record your interest in some |
226 | event. For instance, if you want to wait for STDIN to become readable, |
233 | event. For instance, if you want to wait for STDIN to become readable, |
227 | you would create an EV::io watcher for that: |
234 | you would create an EV::io watcher for that: |
… | |
… | |
770 | embedded loop, other types of watchers might be handled in a delayed or |
777 | embedded loop, other types of watchers might be handled in a delayed or |
771 | incorrect fashion and must not be used). |
778 | incorrect fashion and must not be used). |
772 | |
779 | |
773 | See the libev documentation at |
780 | See the libev documentation at |
774 | <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#code_ev_embed_code |
781 | <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#code_ev_embed_code |
775 | _when_one_backend_> for more details. |
782 | _when_one_backend_> (locally installed as EV::libev) for more details. |
776 | |
783 | |
777 | In short, this watcher is most useful on BSD systems without working |
784 | In short, this watcher is most useful on BSD systems without working |
778 | kqueue to still be able to handle a large number of sockets: |
785 | kqueue to still be able to handle a large number of sockets: |
779 | |
786 | |
780 | my $socket_loop; |
787 | my $socket_loop; |