… | |
… | |
50 | # MAINLOOP |
50 | # MAINLOOP |
51 | EV::loop; # loop until EV::unloop is called or all watchers stop |
51 | EV::loop; # loop until EV::unloop is called or all watchers stop |
52 | EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled |
52 | EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled |
53 | EV::loop EV::LOOP_NONBLOCK; # try to handle same events, but do not block |
53 | EV::loop EV::LOOP_NONBLOCK; # try to handle same events, but do not block |
54 | |
54 | |
|
|
55 | BEFORE YOU START USING THIS MODULE |
|
|
56 | If you only need timer, I/O, signal, child and idle watchers and not the |
|
|
57 | advanced functionality of this module, consider using AnyEvent instead, |
|
|
58 | specifically the simplified API described in AE. |
|
|
59 | |
|
|
60 | When used with EV as backend, the AE API is as fast as the native EV |
|
|
61 | API, but your programs/modules will still run with many other event |
|
|
62 | loops. |
|
|
63 | |
55 | DESCRIPTION |
64 | DESCRIPTION |
56 | This module provides an interface to libev |
65 | This module provides an interface to libev |
57 | (<http://software.schmorp.de/pkg/libev.html>). While the documentation |
66 | (<http://software.schmorp.de/pkg/libev.html>). While the documentation |
58 | below is comprehensive, one might also consult the documentation of |
67 | below is comprehensive, one might also consult the documentation of |
59 | libev itself (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod> or |
68 | libev itself (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod> or |
… | |
… | |
235 | Otherwise a EV::timer with this value will be started. |
244 | Otherwise a EV::timer with this value will be started. |
236 | |
245 | |
237 | When an error occurs or either the timeout or I/O watcher triggers, |
246 | When an error occurs or either the timeout or I/O watcher triggers, |
238 | then the callback will be called with the received event set (in |
247 | then the callback will be called with the received event set (in |
239 | general you can expect it to be a combination of "EV::ERROR", |
248 | general you can expect it to be a combination of "EV::ERROR", |
240 | "EV::READ", "EV::WRITE" and "EV::TIMEOUT"). |
249 | "EV::READ", "EV::WRITE" and "EV::TIMER"). |
241 | |
250 | |
242 | EV::once doesn't return anything: the watchers stay active till |
251 | EV::once doesn't return anything: the watchers stay active till |
243 | either of them triggers, then they will be stopped and freed, and |
252 | either of them triggers, then they will be stopped and freed, and |
244 | the callback invoked. |
253 | the callback invoked. |
245 | |
254 | |
… | |
… | |
290 | |
299 | |
291 | Each watcher type has its associated bit in revents, so you can use the |
300 | Each watcher type has its associated bit in revents, so you can use the |
292 | same callback for multiple watchers. The event mask is named after the |
301 | same callback for multiple watchers. The event mask is named after the |
293 | type, i.e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE, |
302 | type, i.e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE, |
294 | EV::periodic sets EV::PERIODIC and so on, with the exception of I/O |
303 | EV::periodic sets EV::PERIODIC and so on, with the exception of I/O |
295 | events (which can set both EV::READ and EV::WRITE bits), and EV::timer |
304 | events (which can set both EV::READ and EV::WRITE bits). |
296 | (which uses EV::TIMEOUT). |
|
|
297 | |
305 | |
298 | In the rare case where one wants to create a watcher but not start it at |
306 | In the rare case where one wants to create a watcher but not start it at |
299 | the same time, each constructor has a variant with a trailing "_ns" in |
307 | the same time, each constructor has a variant with a trailing "_ns" in |
300 | its name, e.g. EV::io has a non-starting variant EV::io_ns and so on. |
308 | its name, e.g. EV::io has a non-starting variant EV::io_ns and so on. |
301 | |
309 | |