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

Comparing EV/EV.pm (file contents):
Revision 1.6 by root, Sat Oct 27 07:30:10 2007 UTC vs.
Revision 1.7 by root, Sat Oct 27 14:54:20 2007 UTC

101 101
102As long as the returned watcher object is alive, call the C<$callback> 102As long as the returned watcher object is alive, call the C<$callback>
103when the events specified in C<$eventmask> happen. Initially, the timeout 103when the events specified in C<$eventmask> happen. Initially, the timeout
104is disabled. 104is disabled.
105 105
106The C<io_ns> variant doesn't add/start the newly created watcher. 106Youc an additionall set a timeout to occur on the watcher, but note that
107this timeout will not be reset when you get an I/O event in the EV::PERSIST
108case, and reaching a timeout will always stop the watcher even in the
109EV::PERSIST case.
110
111If you want a timeout to occur only after a specific time of inactivity, set
112a repeating timeout and do NOT use EV::PERSIST.
107 113
108Eventmask can be one or more of these constants ORed together: 114Eventmask can be one or more of these constants ORed together:
109 115
110 EV::READ wait until read() wouldn't block anymore 116 EV::READ wait until read() wouldn't block anymore
111 EV::WRITE wait until write() wouldn't block anymore 117 EV::WRITE wait until write() wouldn't block anymore
112 EV::PERSIST stay active after an event occured 118 EV::PERSIST stay active after a (non-timeout) event occured
119
120The C<io_ns> variant doesn't add/start the newly created watcher.
113 121
114=item my $w = EV::timer $after, $repeat, $callback 122=item my $w = EV::timer $after, $repeat, $callback
115 123
116=item my $w = EV::timer_ns $after, $repeat, $callback 124=item my $w = EV::timer_ns $after, $repeat, $callback
117 125
138 146
139This can be used to schedule a callback to run at very regular intervals, 147This can be used to schedule a callback to run at very regular intervals,
140as long as the processing time is less then the interval (otherwise 148as long as the processing time is less then the interval (otherwise
141obviously events will be skipped). 149obviously events will be skipped).
142 150
151Another way to think about it (for the mathematically inclined) is that
152C<timer_abs> will try to tun the callback at the next possible time where
153C<$time = $at (mod $interval)>, regardless of any time jumps.
154
143The C<timer_abs_ns> variant doesn't add/start the newly created watcher. 155The C<timer_abs_ns> variant doesn't add/start the newly created watcher.
144 156
145=item my $w = EV::signal $signum, $callback 157=item my $w = EV::signal $signum, $callback
146 158
147=item my $w = EV::signal_ns $signum, $callback 159=item my $w = EV::signal_ns $signum, $callback
209=head1 BUGS 221=head1 BUGS
210 222
211Lots. Libevent itself isn't well tested and rather buggy, and this module 223Lots. Libevent itself isn't well tested and rather buggy, and this module
212is quite new at the moment. 224is quite new at the moment.
213 225
214Please note that the epoll method is not, in general, reliable in 226Please note that the epoll method is not, in general, reliable in programs
215programs that use fork (even if no libveent calls are being made in the 227that use fork (even if no libveent calls are being made in the forked
216forked process). Since this is such a common issue, this module will 228process). If your program behaves erratically, try setting the environment
217force the epoll method in EV to be off *unless* the global variable 229variable C<EVENT_NOEPOLL> first when running the program.
218$EV::ENABLE_EPOLL is set to 1 *before* loading this module for the first 230
219time. 231In general, if you fork, then you can only use the EV module in one of the
232children.
220 233
221=cut 234=cut
222 235
223our $NPRI = 4; 236our $NPRI = 4;
224our $BASE;
225our $ENABLE_EPOLL;
226
227{
228 local $ENV{EVENT_NOEPOLL};
229 $ENV{EVENT_NOEPOLL} = 1 unless $ENABLE_EPOLL;
230 $BASE = init; 237our $BASE = init;
231}
232
233priority_init $NPRI; 238priority_init $NPRI;
234 239
235push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"]; 240push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"];
236 241
2371; 2421;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines