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

Comparing EV/EV.pm (file contents):
Revision 1.15 by root, Wed Oct 31 18:28:00 2007 UTC vs.
Revision 1.16 by root, Wed Oct 31 20:10:17 2007 UTC

23 }; 23 };
24 24
25 # IO 25 # IO
26 26
27 my $w = EV::io \*STDIN, EV::READ | EV::PERSIST, sub { 27 my $w = EV::io \*STDIN, EV::READ | EV::PERSIST, sub {
28 my ($w, $events) = @_; # all callbacks get the watcher object and event mask 28 my ($w, $revents) = @_; # all callbacks get the watcher object and event mask
29 if ($events & EV::TIMEOUT) { 29 if ($revents & EV::TIMEOUT) {
30 warn "nothing received on stdin for 10 seconds, retrying"; 30 warn "nothing received on stdin for 10 seconds, retrying";
31 } else { 31 } else {
32 warn "stdin is readable, you entered: ", <STDIN>; 32 warn "stdin is readable, you entered: ", <STDIN>;
33 } 33 }
34 }; 34 };
35 $w->timeout (10); 35 $w->timeout (10);
36 36
37 my $w = EV::timed_io \*STDIN, EV::READ, 30, sub { 37 my $w = EV::timed_io \*STDIN, EV::READ, 30, sub {
38 my ($w, $events) = @_; 38 my ($w, $revents) = @_;
39 if ($_[1] & EV::TIMEOUT) { 39 if ($revents & EV::TIMEOUT) {
40 warn "nothing entered within 30 seconds, bye bye.\n"; 40 warn "nothing entered within 30 seconds, bye bye.\n";
41 $w->stop; 41 $w->stop;
42 } else { 42 } else {
43 my $line = <STDIN>; 43 my $line = <STDIN>;
44 warn "you entered something, you again have 30 seconds.\n"; 44 warn "you entered something, you again have 30 seconds.\n";
52 }; 52 };
53 53
54 my $w = EV::signal 3, sub { 54 my $w = EV::signal 3, sub {
55 warn "sigquit received (this is GNU/Linux, right?)\n"; 55 warn "sigquit received (this is GNU/Linux, right?)\n";
56 }; 56 };
57
58 # CHILD/PID STATUS CHANGES
59
60 my $w = EV::child 666, sub {
61 my ($w, $revents, $status) = @_;
62 };
57 63
58 # MAINLOOP 64 # MAINLOOP
59 EV::dispatch; # loop as long as watchers are active 65 EV::dispatch; # loop as long as watchers are active
60 EV::loop; # the same thing 66 EV::loop; # the same thing
61 EV::loop EV::LOOP_ONCE; # block until some events could be handles 67 EV::loop EV::LOOP_ONESHOT; # block until some events could be handles
62 EV::loop EV::LOOP_NONBLOCK; # check and handle some events, but do not wait 68 EV::loop EV::LOOP_NONBLOCK; # check and handle some events, but do not wait
63 69
64=head1 DESCRIPTION 70=head1 DESCRIPTION
65 71
66This module provides an interface to libevent 72This module provides an interface to libev
67(L<http://monkey.org/~provos/libevent/>). You probably should acquaint 73(L<http://software.schmorp.de/pkg/libev.html>). You probably should
68yourself with its documentation and source code to be able to use this 74acquaint yourself with its documentation and source code to be able to use
69module fully. 75this module fully.
70
71Please note thta this module disables the libevent EPOLL method by
72default, see BUGS, below, if you need to enable it.
73 76
74=cut 77=cut
75 78
76package EV; 79package EV;
77 80

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines