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

Comparing EV/EV.pm (file contents):
Revision 1.32 by root, Thu Nov 8 17:02:10 2007 UTC vs.
Revision 1.38 by root, Mon Nov 12 21:51:14 2007 UTC

10 10
11 my $w = EV::timer 2, 0, sub { 11 my $w = EV::timer 2, 0, sub {
12 warn "is called after 2s"; 12 warn "is called after 2s";
13 }; 13 };
14 14
15 my $w = EV::timer 2, 1, sub { 15 my $w = EV::timer 2, 2, sub {
16 warn "is called roughly every 2s (repeat = 1)"; 16 warn "is called roughly every 2s (repeat = 2)";
17 }; 17 };
18 18
19 undef $w; # destroy event watcher again 19 undef $w; # destroy event watcher again
20 20
21 my $w = EV::periodic 0, 60, 0, sub { 21 my $w = EV::periodic 0, 60, 0, sub {
23 }; 23 };
24 24
25 # IO 25 # IO
26 26
27 my $w = EV::io *STDIN, EV::READ, sub { 27 my $w = EV::io *STDIN, EV::READ, sub {
28 my ($w, $revents) = @_; # all callbacks get the watcher object and event mask 28 my ($w, $revents) = @_; # all callbacks receive the watcher and event mask
29 warn "stdin is readable, you entered: ", <STDIN>; 29 warn "stdin is readable, you entered: ", <STDIN>;
30 }; 30 };
31 31
32 # SIGNALS 32 # SIGNALS
33 33
34 my $w = EV::signal 'QUIT', sub { 34 my $w = EV::signal 'QUIT', sub {
35 warn "sigquit received\n"; 35 warn "sigquit received\n";
36 }; 36 };
37 37
38 my $w = EV::signal 3, sub {
39 warn "sigquit received (this is GNU/Linux, right?)\n";
40 };
41
42 # CHILD/PID STATUS CHANGES 38 # CHILD/PID STATUS CHANGES
43 39
44 my $w = EV::child 666, sub { 40 my $w = EV::child 666, sub {
45 my ($w, $revents) = @_; 41 my ($w, $revents) = @_;
46 # my $pid = $w->rpid;
47 my $status = $w->rstatus; 42 my $status = $w->rstatus;
48 }; 43 };
49 44
50 # MAINLOOP 45 # MAINLOOP
51 EV::loop; # loop until EV::loop_done is called 46 EV::loop; # loop until EV::loop_done is called or all watchers stop
52 EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled 47 EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled
53 EV::loop EV::LOOP_NONBLOCK; # try to handle same events, but do not block 48 EV::loop EV::LOOP_NONBLOCK; # try to handle same events, but do not block
54 49
55=head1 DESCRIPTION 50=head1 DESCRIPTION
56 51
62package EV; 57package EV;
63 58
64use strict; 59use strict;
65 60
66BEGIN { 61BEGIN {
67 our $VERSION = '0.6'; 62 our $VERSION = '0.9';
68 use XSLoader; 63 use XSLoader;
69 XSLoader::load "EV", $VERSION; 64 XSLoader::load "EV", $VERSION;
70} 65}
71 66
72@EV::Io::ISA = 67@EV::Io::ISA =
341possible time where C<$time = $at (mod $interval)>, regardless of any time 336possible time where C<$time = $at (mod $interval)>, regardless of any time
342jumps. 337jumps.
343 338
344=item * manual reschedule mode ($reschedule_cb = coderef) 339=item * manual reschedule mode ($reschedule_cb = coderef)
345 340
346In this mode $interval and $at are both being ignored. Instead, each time 341In this mode $interval and $at are both being ignored. Instead, each
347the periodic watcher gets scheduled, the first callback ($reschedule_cb) 342time the periodic watcher gets scheduled, the reschedule callback
348will be called with the watcher as first, and the current time as second 343($reschedule_cb) will be called with the watcher as first, and the current
349argument. 344time as second argument.
350 345
351I<This callback MUST NOT stop or destroy this or any other periodic 346I<This callback MUST NOT stop or destroy this or any other periodic
352watcher, ever>. If you need to stop it, return 1e30 and stop it 347watcher, ever>. If you need to stop it, return 1e30 and stop it
353afterwards. 348afterwards.
354 349
543}; 538};
544 539
545default_loop 540default_loop
546 or die 'EV: cannot initialise libev backend. bad $ENV{LIBEV_METHODS}?'; 541 or die 'EV: cannot initialise libev backend. bad $ENV{LIBEV_METHODS}?';
547 542
548push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"];
549
5501; 5431;
551 544
552=head1 SEE ALSO 545=head1 SEE ALSO
553 546
554 L<EV::DNS>, L<EV::AnyEvent>. 547 L<EV::DNS>, L<EV::AnyEvent>.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines