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

Comparing EV/EV.pm (file contents):
Revision 1.105 by root, Thu Oct 2 12:27:55 2008 UTC vs.
Revision 1.111 by root, Wed Jan 7 20:53:29 2009 UTC

68can use it through the L<AnyEvent> module, stay portable to other event 68can use it through the L<AnyEvent> module, stay portable to other event
69loops (if you don't rely on any watcher types not available through it) 69loops (if you don't rely on any watcher types not available through it)
70and still be faster than with any other event loop currently supported in 70and still be faster than with any other event loop currently supported in
71Perl. 71Perl.
72 72
73=head2 MODULE EXPORTS
74
75This module does not export any symbols.
76
73=cut 77=cut
74 78
75package EV; 79package EV;
76 80
77no warnings; 81no warnings;
78use strict; 82use strict;
79 83
80BEGIN { 84BEGIN {
81 our $VERSION = '3.44'; 85 our $VERSION = '3.52';
82 use XSLoader; 86 use XSLoader;
83 XSLoader::load "EV", $VERSION; 87 XSLoader::load "EV", $VERSION;
84} 88}
85 89
86@EV::IO::ISA = 90@EV::IO::ISA =
113default loop as this is fastest (perl-wise), best supported by other 117default loop as this is fastest (perl-wise), best supported by other
114modules (e.g. AnyEvent or Coro) and most portable event loop. 118modules (e.g. AnyEvent or Coro) and most portable event loop.
115 119
116For specific programs you can create additional event loops dynamically. 120For specific programs you can create additional event loops dynamically.
117 121
118If 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
119sockets 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
120I<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
121will 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
122the 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.
123 127
195=item $time = EV::now 199=item $time = EV::now
196 200
197=item $time = $loop->now 201=item $time = $loop->now
198 202
199Returns the time the last event loop iteration has been started. This 203Returns the time the last event loop iteration has been started. This
200is 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
201usually faster then calling EV::time. 205usually faster then calling EV::time.
202 206
203=item $backend = EV::backend 207=item $backend = EV::backend
204 208
205=item $backend = $loop->backend 209=item $backend = $loop->backend
206 210
207Returns an integer describing the backend used by libev (EV::METHOD_SELECT 211Returns an integer describing the backend used by libev (EV::BACKEND_SELECT
208or EV::METHOD_EPOLL). 212or EV::BACKEND_EPOLL).
209 213
210=item EV::loop [$flags] 214=item EV::loop [$flags]
211 215
212=item $loop->loop ([$flags]) 216=item $loop->loop ([$flags])
213 217
233=item $count = EV::loop_count 237=item $count = EV::loop_count
234 238
235=item $count = $loop->loop_count 239=item $count = $loop->loop_count
236 240
237Return the number of times the event loop has polled for new 241Return the number of times the event loop has polled for new
238events. Sometiems useful as a generation counter. 242events. Sometimes useful as a generation counter.
239 243
240=item EV::once $fh_or_undef, $events, $timeout, $cb->($revents) 244=item EV::once $fh_or_undef, $events, $timeout, $cb->($revents)
241 245
242=item $loop->once ($fh_or_undef, $events, $timeout, $cb->($revents)) 246=item $loop->once ($fh_or_undef, $events, $timeout, $cb->($revents))
243 247
307called 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
308events. 312events.
309 313
310Each 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
311same callback for multiple watchers. The event mask is named after the 315same callback for multiple watchers. The event mask is named after the
312type, 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,
313EV::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
314(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
315uses EV::TIMEOUT). 319uses EV::TIMEOUT).
316 320
317In 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
413because you happen to have this long-running UDP port watcher. 417because you happen to have this long-running UDP port watcher.
414 418
415In 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
416though 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.
417 421
418The 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
419any time. 423any time.
420 424
421Example: 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
422event loop from running just because of that watcher. 426event loop from running just because of that watcher.
423 427
917 # make the dispatcher handle any new stuff 921 # make the dispatcher handle any new stuff
918 ... not shown 922 ... not shown
919 }; 923 };
920 924
921The 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
922are destroyed before this cna happen (remember EV::check gets called 926are destroyed before this can happen (remember EV::check gets called
923first). 927first).
924 928
925The 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.
926 930
927=back 931=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines