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

Comparing EV/EV.pm (file contents):
Revision 1.9 by root, Sun Oct 28 06:40:46 2007 UTC vs.
Revision 1.10 by root, Mon Oct 29 07:24:37 2007 UTC

25 }; 25 };
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, $events) = @_; # all callbacks get the watcher object and event mask
29 if ($events & EV::TIMEOUT) { 29 if ($events & EV::TIMEOUT) {
30 warn "nothign 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);
109 109
110As long as the returned watcher object is alive, call the C<$callback> 110As long as the returned watcher object is alive, call the C<$callback>
111when the events specified in C<$eventmask> happen. Initially, the timeout 111when the events specified in C<$eventmask> happen. Initially, the timeout
112is disabled. 112is disabled.
113 113
114Youc an additionall set a timeout to occur on the watcher, but note that 114You can additionall set a timeout to occur on the watcher, but note that
115this timeout will not be reset when you get an I/O event in the EV::PERSIST 115this timeout will not be reset when you get an I/O event in the EV::PERSIST
116case, and reaching a timeout will always stop the watcher even in the 116case, and reaching a timeout will always stop the watcher even in the
117EV::PERSIST case. 117EV::PERSIST case.
118 118
119If you want a timeout to occur only after a specific time of inactivity, set 119If you want a timeout to occur only after a specific time of inactivity, set
124 EV::READ wait until read() wouldn't block anymore 124 EV::READ wait until read() wouldn't block anymore
125 EV::WRITE wait until write() wouldn't block anymore 125 EV::WRITE wait until write() wouldn't block anymore
126 EV::PERSIST stay active after a (non-timeout) event occured 126 EV::PERSIST stay active after a (non-timeout) event occured
127 127
128The C<io_ns> variant doesn't add/start the newly created watcher. 128The C<io_ns> variant doesn't add/start the newly created watcher.
129
130=item my $w = EV::timed_io $fileno_or_fh, $eventmask, $timeout, $callback
131
132=item my $w = EV::timed_io_ns $fileno_or_fh, $eventmask, $timeout, $callback
133
134Same as C<io> and C<io_ns>, but also specifies a timeout (as if there was
135a call to C<< $w->timeout ($timout, 1) >>. The persist flag is not allowed
136and will automatically be cleared. The watcher will be restarted after each event.
137
138If the timeout is zero or undef, no timeout will be set, and a normal
139watcher (with the persist flag set!) will be created.
140
141This has the effect of timing out after the specified period of inactivity
142has happened.
143
144Due to the design of libevent, this is also relatively inefficient, having
145one or two io watchers and a separate timeout watcher that you reset on
146activity (by calling its C<start> method) is usually more efficient.
129 147
130=item my $w = EV::timer $after, $repeat, $callback 148=item my $w = EV::timer $after, $repeat, $callback
131 149
132=item my $w = EV::timer_ns $after, $repeat, $callback 150=item my $w = EV::timer_ns $after, $repeat, $callback
133 151
202 220
203=item $current_fh = $w->fh 221=item $current_fh = $w->fh
204 222
205=item $old_fh = $w->fh ($new_fh) 223=item $old_fh = $w->fh ($new_fh)
206 224
207Returns the previously set filehandle and optionally set a new one. 225Returns the previously set filehandle and optionally set a new one (also
226clears the EV::SIGNAL flag when setting a filehandle).
227
228=item $current_signal = $w->signal
229
230=item $old_signal = $w->signal ($new_signal)
231
232Returns the previously set signal number and optionally set a new one (also sets
233the EV::SIGNAL flag when setting a signal).
208 234
209=item $current_eventmask = $w->events 235=item $current_eventmask = $w->events
210 236
211=item $old_eventmask = $w->events ($new_eventmask) 237=item $old_eventmask = $w->events ($new_eventmask)
212 238

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines