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

Comparing EV/EV.pm (file contents):
Revision 1.47 by root, Fri Nov 23 13:08:55 2007 UTC vs.
Revision 1.51 by root, Sat Nov 24 16:12:37 2007 UTC

57package EV; 57package EV;
58 58
59use strict; 59use strict;
60 60
61BEGIN { 61BEGIN {
62 our $VERSION = '1.2'; 62 our $VERSION = '1.3';
63 use XSLoader; 63 use XSLoader;
64 XSLoader::load "EV", $VERSION; 64 XSLoader::load "EV", $VERSION;
65} 65}
66 66
67@EV::Io::ISA = 67@EV::IO::ISA =
68@EV::Timer::ISA = 68@EV::Timer::ISA =
69@EV::Periodic::ISA = 69@EV::Periodic::ISA =
70@EV::Signal::ISA = 70@EV::Signal::ISA =
71@EV::Idle::ISA = 71@EV::Idle::ISA =
72@EV::Prepare::ISA = 72@EV::Prepare::ISA =
117innermost call to EV::loop return. 117innermost call to EV::loop return.
118 118
119When called with an argument of EV::UNLOOP_ALL, all calls to EV::loop will return as 119When called with an argument of EV::UNLOOP_ALL, all calls to EV::loop will return as
120fast as possible. 120fast as possible.
121 121
122=item EV::once $fh_or_undef, $events, $timeout, $cb->($events) 122=item EV::once $fh_or_undef, $events, $timeout, $cb->($revents)
123 123
124This function rolls together an I/O and a timer watcher for a single 124This function rolls together an I/O and a timer watcher for a single
125one-shot event without the need for managing a watcher object. 125one-shot event without the need for managing a watcher object.
126 126
127If C<$fh_or_undef> is a filehandle or file descriptor, then C<$events> 127If C<$fh_or_undef> is a filehandle or file descriptor, then C<$events>
233watchers with higher priority will be invoked first. The valid range of 233watchers with higher priority will be invoked first. The valid range of
234priorities lies between EV::MAXPRI (default 2) and EV::MINPRI (default 234priorities lies between EV::MAXPRI (default 2) and EV::MINPRI (default
235-2). If the priority is outside this range it will automatically be 235-2). If the priority is outside this range it will automatically be
236normalised to the nearest valid priority. 236normalised to the nearest valid priority.
237 237
238The default priority of any newly-created weatcher is 0. 238The default priority of any newly-created watcher is 0.
239
240Note that the priority semantics have not yet been fleshed out and are
241subject to almost certain change.
239 242
240=item $w->trigger ($revents) 243=item $w->trigger ($revents)
241 244
242Call the callback *now* with the given event mask. 245Call the callback *now* with the given event mask.
243 246
247=item $previous_state = $w->keepalive ($bool)
248
249Normally, C<EV::loop> will return when there are no active watchers
250(which is a "deadlock" because no progress can be made anymore). This is
251convinient because it allows you to start your watchers (and your jobs),
252call C<EV::loop> once and when it returns you know that all your jobs are
253finished (or they forgot to register some watchers for their task :).
254
255Sometimes, however, this gets in your way, for example when you the module
256that calls C<EV::loop> (usually the main program) is not the same module
257as a long-living watcher (for example a DNS client module written by
258somebody else even). Then you might want any outstanding requests to be
259handled, but you would not want to keep C<EV::loop> from returning just
260because you happen to have this long-running UDP port watcher.
261
262In this case you can clear the keepalive status, which means that even
263though your watcher is active, it won't keep C<EV::loop> from returning.
264
265The initial value for keepalive is true (enabled), and you cna change it
266any time.
267
268Example: Register an IO watcher for some UDP socket but do not keep the
269event loop from running just because of that watcher.
270
271 my $udp_socket = ...
272 my $udp_watcher = EV::io $udp_socket, EV::READ, sub { ... };
273 $udp_watcher->keepalive (0);
244 274
245=item $w = EV::io $fileno_or_fh, $eventmask, $callback 275=item $w = EV::io $fileno_or_fh, $eventmask, $callback
246 276
247=item $w = EV::io_ns $fileno_or_fh, $eventmask, $callback 277=item $w = EV::io_ns $fileno_or_fh, $eventmask, $callback
248 278

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines