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

Comparing EV/EV.pm (file contents):
Revision 1.20 by root, Thu Nov 1 17:17:32 2007 UTC vs.
Revision 1.26 by root, Fri Nov 2 23:22:17 2007 UTC

60package EV; 60package EV;
61 61
62use strict; 62use strict;
63 63
64BEGIN { 64BEGIN {
65 our $VERSION = '0.1'; 65 our $VERSION = '0.5';
66 use XSLoader; 66 use XSLoader;
67 XSLoader::load "EV", $VERSION; 67 XSLoader::load "EV", $VERSION;
68} 68}
69 69
70@EV::Io::ISA = 70@EV::Io::ISA =
150In the rare case where one wants to create a watcher but not start it at 150In the rare case where one wants to create a watcher but not start it at
151the same time, each constructor has a variant with a trailing C<_ns> in 151the same time, each constructor has a variant with a trailing C<_ns> in
152its name, e.g. EV::io has a non-starting variant EV::io_ns and so on. 152its name, e.g. EV::io has a non-starting variant EV::io_ns and so on.
153 153
154Please note that a watcher will automatically be stopped when the watcher 154Please note that a watcher will automatically be stopped when the watcher
155object is returned, so you I<need> to keep the watcher objects returned by 155object is destroyed, so you I<need> to keep the watcher objects returned by
156the constructors. 156the constructors.
157
158Also, all methods changing some aspect of a watcher (->set, ->priority,
159->fh and so on) automatically stop and start it again if it is active,
160which means pending events get lost.
157 161
158=head2 WATCHER TYPES 162=head2 WATCHER TYPES
159 163
160Now lets move to the existing watcher types and asociated methods. 164Now lets move to the existing watcher types and asociated methods.
161 165
184 188
185=item $current_cb = $w->cb 189=item $current_cb = $w->cb
186 190
187=item $old_cb = $w->cb ($new_cb) 191=item $old_cb = $w->cb ($new_cb)
188 192
189Queries the callback on the watcher and optionally changes it. You cna do 193Queries the callback on the watcher and optionally changes it. You can do
190this at any time. 194this at any time without the watcher restarting.
195
196=item $current_priority = $w->priority
197
198=item $old_priority = $w->priority ($new_priority)
199
200Queries the priority on the watcher and optionally changes it. Pending
201watchers with higher priority will be invoked first. The valid range of
202priorities lies between EV::MAXPRI (default 2) and EV::MINPRI (default
203-2). If the priority is outside this range it will automatically be
204normalised to the nearest valid priority.
205
206The default priority of any newly-created weatcher is 0.
191 207
192=item $w->trigger ($revents) 208=item $w->trigger ($revents)
193 209
194Call the callback *now* with the given event mask. 210Call the callback *now* with the given event mask.
195 211
291EV::periodic will try to run the callback at the next possible time where 307EV::periodic will try to run the callback at the next possible time where
292C<$time = $at (mod $interval)>, regardless of any time jumps. 308C<$time = $at (mod $interval)>, regardless of any time jumps.
293 309
294This periodic timer is based on "wallclock time", that is, if the clock 310This periodic timer is based on "wallclock time", that is, if the clock
295changes (C<ntp>, C<date -s> etc.), then the timer will nevertheless run at 311changes (C<ntp>, C<date -s> etc.), then the timer will nevertheless run at
296the specified time. 312the specified time. This means it will never drift (it might jitter, but
313it will not drift).
297 314
298The C<periodic_ns> variant doesn't start (activate) the newly created watcher. 315The C<periodic_ns> variant doesn't start (activate) the newly created watcher.
299 316
300=item $w->set ($at, $interval) 317=item $w->set ($at, $interval)
301 318
322=item $w->set ($signal) 339=item $w->set ($signal)
323 340
324Reconfigures the watcher, see the constructor above for details. Can be at 341Reconfigures the watcher, see the constructor above for details. Can be at
325any time. 342any time.
326 343
344=item $current_signum = $w->signal
345
346=item $old_signum = $w->signal ($new_signal)
347
348Returns the previously set signal (always as a number not name) and
349optionally set a new one.
350
327 351
328=item $w = EV::child $pid, $callback 352=item $w = EV::child $pid, $callback
329 353
330=item $w = EV::child_ns $pid, $callback 354=item $w = EV::child_ns $pid, $callback
331 355
344 368
345=item $w->set ($pid) 369=item $w->set ($pid)
346 370
347Reconfigures the watcher, see the constructor above for details. Can be at 371Reconfigures the watcher, see the constructor above for details. Can be at
348any time. 372any time.
373
374=item $current_pid = $w->pid
375
376=item $old_pid = $w->pid ($new_pid)
377
378Returns the previously set process id and optionally set a new one.
349 379
350 380
351=item $w = EV::idle $callback 381=item $w = EV::idle $callback
352 382
353=item $w = EV::idle_ns $callback 383=item $w = EV::idle_ns $callback
434 464
435our $DIED = sub { 465our $DIED = sub {
436 warn "EV: error in callback (ignoring): $@"; 466 warn "EV: error in callback (ignoring): $@";
437}; 467};
438 468
439init; 469init
470 or die 'EV: cannot initialise libev backend. bad $ENV{LIBEV_METHODS}?';
440 471
441push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"]; 472push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"];
442 473
4431; 4741;
444 475

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines