… | |
… | |
80 | |
80 | |
81 | no warnings; |
81 | no warnings; |
82 | use strict; |
82 | use strict; |
83 | |
83 | |
84 | BEGIN { |
84 | BEGIN { |
85 | our $VERSION = '3.45'; |
85 | our $VERSION = '3.51'; |
86 | use XSLoader; |
86 | use XSLoader; |
87 | XSLoader::load "EV", $VERSION; |
87 | XSLoader::load "EV", $VERSION; |
88 | } |
88 | } |
89 | |
89 | |
90 | @EV::IO::ISA = |
90 | @EV::IO::ISA = |
… | |
… | |
117 | default loop as this is fastest (perl-wise), best supported by other |
117 | default loop as this is fastest (perl-wise), best supported by other |
118 | modules (e.g. AnyEvent or Coro) and most portable event loop. |
118 | modules (e.g. AnyEvent or Coro) and most portable event loop. |
119 | |
119 | |
120 | For specific programs you can create additional event loops dynamically. |
120 | For specific programs you can create additional event loops dynamically. |
121 | |
121 | |
122 | If you want to take avdantage of kqueue (which often works properly for |
122 | If you want to take advantage of kqueue (which often works properly for |
123 | sockets only) even though the default loop doesn't enable it, you can |
123 | sockets only) even though the default loop doesn't enable it, you can |
124 | I<embed> a kqueue loop into the default loop: running the default loop |
124 | I<embed> a kqueue loop into the default loop: running the default loop |
125 | will then also service the kqueue loop to some extent. See the example in |
125 | will then also service the kqueue loop to some extent. See the example in |
126 | the section about embed watchers for an example on how to achieve that. |
126 | the section about embed watchers for an example on how to achieve that. |
127 | |
127 | |
… | |
… | |
199 | =item $time = EV::now |
199 | =item $time = EV::now |
200 | |
200 | |
201 | =item $time = $loop->now |
201 | =item $time = $loop->now |
202 | |
202 | |
203 | Returns the time the last event loop iteration has been started. This |
203 | Returns the time the last event loop iteration has been started. This |
204 | is the time that (relative) timers are based on, and refering to it is |
204 | is the time that (relative) timers are based on, and referring to it is |
205 | usually faster then calling EV::time. |
205 | usually faster then calling EV::time. |
206 | |
206 | |
207 | =item $backend = EV::backend |
207 | =item $backend = EV::backend |
208 | |
208 | |
209 | =item $backend = $loop->backend |
209 | =item $backend = $loop->backend |
210 | |
210 | |
211 | Returns an integer describing the backend used by libev (EV::METHOD_SELECT |
211 | Returns an integer describing the backend used by libev (EV::BACKEND_SELECT |
212 | or EV::METHOD_EPOLL). |
212 | or EV::BACKEND_EPOLL). |
213 | |
213 | |
214 | =item EV::loop [$flags] |
214 | =item EV::loop [$flags] |
215 | |
215 | |
216 | =item $loop->loop ([$flags]) |
216 | =item $loop->loop ([$flags]) |
217 | |
217 | |
… | |
… | |
237 | =item $count = EV::loop_count |
237 | =item $count = EV::loop_count |
238 | |
238 | |
239 | =item $count = $loop->loop_count |
239 | =item $count = $loop->loop_count |
240 | |
240 | |
241 | Return the number of times the event loop has polled for new |
241 | Return the number of times the event loop has polled for new |
242 | events. Sometiems useful as a generation counter. |
242 | events. Sometimes useful as a generation counter. |
243 | |
243 | |
244 | =item EV::once $fh_or_undef, $events, $timeout, $cb->($revents) |
244 | =item EV::once $fh_or_undef, $events, $timeout, $cb->($revents) |
245 | |
245 | |
246 | =item $loop->once ($fh_or_undef, $events, $timeout, $cb->($revents)) |
246 | =item $loop->once ($fh_or_undef, $events, $timeout, $cb->($revents)) |
247 | |
247 | |
… | |
… | |
311 | called with at least two arguments: the watcher and a bitmask of received |
311 | called with at least two arguments: the watcher and a bitmask of received |
312 | events. |
312 | events. |
313 | |
313 | |
314 | Each watcher type has its associated bit in revents, so you can use the |
314 | Each watcher type has its associated bit in revents, so you can use the |
315 | same callback for multiple watchers. The event mask is named after the |
315 | same callback for multiple watchers. The event mask is named after the |
316 | type, i..e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE, |
316 | type, i.e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE, |
317 | EV::periodic sets EV::PERIODIC and so on, with the exception of I/O events |
317 | EV::periodic sets EV::PERIODIC and so on, with the exception of I/O events |
318 | (which can set both EV::READ and EV::WRITE bits), and EV::timer (which |
318 | (which can set both EV::READ and EV::WRITE bits), and EV::timer (which |
319 | uses EV::TIMEOUT). |
319 | uses EV::TIMEOUT). |
320 | |
320 | |
321 | In the rare case where one wants to create a watcher but not start it at |
321 | In the rare case where one wants to create a watcher but not start it at |
… | |
… | |
417 | because you happen to have this long-running UDP port watcher. |
417 | because you happen to have this long-running UDP port watcher. |
418 | |
418 | |
419 | In this case you can clear the keepalive status, which means that even |
419 | In this case you can clear the keepalive status, which means that even |
420 | though your watcher is active, it won't keep C<EV::loop> from returning. |
420 | though your watcher is active, it won't keep C<EV::loop> from returning. |
421 | |
421 | |
422 | The initial value for keepalive is true (enabled), and you cna change it |
422 | The initial value for keepalive is true (enabled), and you can change it |
423 | any time. |
423 | any time. |
424 | |
424 | |
425 | Example: Register an I/O watcher for some UDP socket but do not keep the |
425 | Example: Register an I/O watcher for some UDP socket but do not keep the |
426 | event loop from running just because of that watcher. |
426 | event loop from running just because of that watcher. |
427 | |
427 | |
… | |
… | |
921 | # make the dispatcher handle any new stuff |
921 | # make the dispatcher handle any new stuff |
922 | ... not shown |
922 | ... not shown |
923 | }; |
923 | }; |
924 | |
924 | |
925 | The callbacks of the created watchers will not be called as the watchers |
925 | The callbacks of the created watchers will not be called as the watchers |
926 | are destroyed before this cna happen (remember EV::check gets called |
926 | are destroyed before this can happen (remember EV::check gets called |
927 | first). |
927 | first). |
928 | |
928 | |
929 | The C<check_ns> variant doesn't start (activate) the newly created watcher. |
929 | The C<check_ns> variant doesn't start (activate) the newly created watcher. |
930 | |
930 | |
931 | =back |
931 | =back |