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

Comparing EV/EV.pm (file contents):
Revision 1.107 by root, Thu Oct 30 08:10:38 2008 UTC vs.
Revision 1.108 by root, Mon Nov 3 12:13:15 2008 UTC

117default loop as this is fastest (perl-wise), best supported by other 117default loop as this is fastest (perl-wise), best supported by other
118modules (e.g. AnyEvent or Coro) and most portable event loop. 118modules (e.g. AnyEvent or Coro) and most portable event loop.
119 119
120For specific programs you can create additional event loops dynamically. 120For specific programs you can create additional event loops dynamically.
121 121
122If you want to take avdantage of kqueue (which often works properly for 122If you want to take advantage of kqueue (which often works properly for
123sockets only) even though the default loop doesn't enable it, you can 123sockets only) even though the default loop doesn't enable it, you can
124I<embed> a kqueue loop into the default loop: running the default loop 124I<embed> a kqueue loop into the default loop: running the default loop
125will then also service the kqueue loop to some extent. See the example in 125will then also service the kqueue loop to some extent. See the example in
126the section about embed watchers for an example on how to achieve that. 126the 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
203Returns the time the last event loop iteration has been started. This 203Returns the time the last event loop iteration has been started. This
204is the time that (relative) timers are based on, and refering to it is 204is the time that (relative) timers are based on, and referring to it is
205usually faster then calling EV::time. 205usually 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
211Returns an integer describing the backend used by libev (EV::METHOD_SELECT 211Returns an integer describing the backend used by libev (EV::BACKEND_SELECT
212or EV::METHOD_EPOLL). 212or 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
241Return the number of times the event loop has polled for new 241Return the number of times the event loop has polled for new
242events. Sometiems useful as a generation counter. 242events. 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
311called with at least two arguments: the watcher and a bitmask of received 311called with at least two arguments: the watcher and a bitmask of received
312events. 312events.
313 313
314Each watcher type has its associated bit in revents, so you can use the 314Each watcher type has its associated bit in revents, so you can use the
315same callback for multiple watchers. The event mask is named after the 315same callback for multiple watchers. The event mask is named after the
316type, i..e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE, 316type, i.e. EV::child sets EV::CHILD, EV::prepare sets EV::PREPARE,
317EV::periodic sets EV::PERIODIC and so on, with the exception of I/O events 317EV::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
319uses EV::TIMEOUT). 319uses EV::TIMEOUT).
320 320
321In the rare case where one wants to create a watcher but not start it at 321In the rare case where one wants to create a watcher but not start it at
417because you happen to have this long-running UDP port watcher. 417because you happen to have this long-running UDP port watcher.
418 418
419In this case you can clear the keepalive status, which means that even 419In this case you can clear the keepalive status, which means that even
420though your watcher is active, it won't keep C<EV::loop> from returning. 420though your watcher is active, it won't keep C<EV::loop> from returning.
421 421
422The initial value for keepalive is true (enabled), and you cna change it 422The initial value for keepalive is true (enabled), and you can change it
423any time. 423any time.
424 424
425Example: Register an I/O watcher for some UDP socket but do not keep the 425Example: Register an I/O watcher for some UDP socket but do not keep the
426event loop from running just because of that watcher. 426event 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
925The callbacks of the created watchers will not be called as the watchers 925The callbacks of the created watchers will not be called as the watchers
926are destroyed before this cna happen (remember EV::check gets called 926are destroyed before this can happen (remember EV::check gets called
927first). 927first).
928 928
929The C<check_ns> variant doesn't start (activate) the newly created watcher. 929The C<check_ns> variant doesn't start (activate) the newly created watcher.
930 930
931=back 931=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines