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

Comparing EV/README (file contents):
Revision 1.4 by root, Mon Oct 29 19:53:21 2007 UTC vs.
Revision 1.5 by root, Thu Nov 1 13:33:12 2007 UTC

21 }; 21 };
22 22
23 # IO 23 # IO
24 24
25 my $w = EV::io \*STDIN, EV::READ | EV::PERSIST, sub { 25 my $w = EV::io \*STDIN, EV::READ | EV::PERSIST, sub {
26 my ($w, $events) = @_; # all callbacks get the watcher object and event mask 26 my ($w, $revents) = @_; # all callbacks get the watcher object and event mask
27 if ($events & EV::TIMEOUT) { 27 if ($revents & EV::TIMEOUT) {
28 warn "nothing received on stdin for 10 seconds, retrying"; 28 warn "nothing received on stdin for 10 seconds, retrying";
29 } else { 29 } else {
30 warn "stdin is readable, you entered: ", <STDIN>; 30 warn "stdin is readable, you entered: ", <STDIN>;
31 } 31 }
32 }; 32 };
33 $w->timeout (10); 33 $w->timeout (10);
34 34
35 my $w = EV::timed_io \*STDIN, EV::READ, 30, sub { 35 my $w = EV::timed_io \*STDIN, EV::READ, 30, sub {
36 my ($w, $events) = @_; 36 my ($w, $revents) = @_;
37 if ($_[1] & EV::TIMEOUT) { 37 if ($revents & EV::TIMEOUT) {
38 warn "nothing entered within 30 seconds, bye bye.\n"; 38 warn "nothing entered within 30 seconds, bye bye.\n";
39 $w->stop; 39 $w->stop;
40 } else { 40 } else {
41 my $line = <STDIN>; 41 my $line = <STDIN>;
42 warn "you entered something, you again have 30 seconds.\n"; 42 warn "you entered something, you again have 30 seconds.\n";
50 }; 50 };
51 51
52 my $w = EV::signal 3, sub { 52 my $w = EV::signal 3, sub {
53 warn "sigquit received (this is GNU/Linux, right?)\n"; 53 warn "sigquit received (this is GNU/Linux, right?)\n";
54 }; 54 };
55
56 # CHILD/PID STATUS CHANGES
57
58 my $w = EV::child 666, sub {
59 my ($w, $revents, $status) = @_;
60 };
55 61
56 # MAINLOOP 62 # MAINLOOP
57 EV::dispatch; # loop as long as watchers are active 63 EV::dispatch; # loop as long as watchers are active
58 EV::loop; # the same thing 64 EV::loop; # the same thing
59 EV::loop EV::LOOP_ONCE; # block until some events could be handles 65 EV::loop EV::LOOP_ONESHOT; # block until some events could be handles
60 EV::loop EV::LOOP_NONBLOCK; # check and handle some events, but do not wait 66 EV::loop EV::LOOP_NONBLOCK; # check and handle some events, but do not wait
61 67
62DESCRIPTION 68DESCRIPTION
63 This module provides an interface to libevent 69 This module provides an interface to libev
64 (<http://monkey.org/~provos/libevent/>). You probably should acquaint 70 (<http://software.schmorp.de/pkg/libev.html>). You probably should
65 yourself with its documentation and source code to be able to use this 71 acquaint yourself with its documentation and source code to be able to
66 module fully. 72 use this module fully.
67
68 Please note thta this module disables the libevent EPOLL method by
69 default, see BUGS, below, if you need to enable it.
70 73
71BASIC INTERFACE 74BASIC INTERFACE
72 $EV::NPRI 75 $EV::NPRI
73 How many priority levels are available. 76 How many priority levels are available.
74 77
230 233
231 $w->priority_set ($priority) 234 $w->priority_set ($priority)
232 Set the priority of the watcher to $priority (0 <= $priority < 235 Set the priority of the watcher to $priority (0 <= $priority <
233 $EV::NPRI). 236 $EV::NPRI).
234 237
235BUGS 238THREADS
236 Lots. Libevent itself isn't well tested and rather buggy, and this 239 Threads are not supported by this in any way. Perl pseudo-threads is
237 module is quite new at the moment. 240 evil and must die.
238
239 Please note that the epoll method is not, in general, reliable in
240 programs that use fork (even if no libveent calls are being made in the
241 forked process). If your program behaves erratically, try setting the
242 environment variable "EVENT_NOEPOLL" first when running the program.
243
244 In general, if you fork, then you can only use the EV module in one of
245 the children.
246 241
247SEE ALSO 242SEE ALSO
248 L<EV::DNS>, L<event(3)>, L<event.h>, L<evdns.h>. 243 L<EV::DNS>, L<event(3)>, L<event.h>, L<evdns.h>.
249 L<EV::AnyEvent>. 244 L<EV::AnyEvent>.
250 245

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines