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

Comparing EV/EV.pm (file contents):
Revision 1.34 by root, Fri Nov 9 19:38:56 2007 UTC vs.
Revision 1.35 by root, Sat Nov 10 05:31:48 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines