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

Comparing EV/EV.pm (file contents):
Revision 1.2 by root, Fri Oct 26 17:24:17 2007 UTC vs.
Revision 1.7 by root, Sat Oct 27 14:54:20 2007 UTC

41 EV::loop EV::LOOP_ONSHOT; 41 EV::loop EV::LOOP_ONSHOT;
42 42
43=head1 DESCRIPTION 43=head1 DESCRIPTION
44 44
45This module provides an interface to libevent 45This module provides an interface to libevent
46(L<http://monkey.org/~provos/libevent/>). 46(L<http://monkey.org/~provos/libevent/>). You probably should acquaint
47yourself with its documentation and source code to be able to use this
48module fully.
49
50Please note thta this module disables the libevent EPOLL method by
51default, see BUGS, below, if you need to enable it.
47 52
48=cut 53=cut
49 54
50package EV; 55package EV;
51 56
96 101
97As 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>
98when the events specified in C<$eventmask> happen. Initially, the timeout 103when the events specified in C<$eventmask> happen. Initially, the timeout
99is disabled. 104is disabled.
100 105
101The 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.
102 113
103Eventmask can be one or more of these constants ORed together: 114Eventmask can be one or more of these constants ORed together:
104 115
105 EV::READ wait until read() wouldn't block anymore 116 EV::READ wait until read() wouldn't block anymore
106 EV::WRITE wait until write() wouldn't block anymore 117 EV::WRITE wait until write() wouldn't block anymore
107 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.
108 121
109=item my $w = EV::timer $after, $repeat, $callback 122=item my $w = EV::timer $after, $repeat, $callback
110 123
111=item my $w = EV::timer_ns $after, $repeat, $callback 124=item my $w = EV::timer_ns $after, $repeat, $callback
112 125
133 146
134This 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,
135as long as the processing time is less then the interval (otherwise 148as long as the processing time is less then the interval (otherwise
136obviously events will be skipped). 149obviously events will be skipped).
137 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
138The 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.
139 156
140=item my $w = EV::signal $signum, $callback 157=item my $w = EV::signal $signum, $callback
141 158
142=item my $w = EV::signal_ns $signum, $callback 159=item my $w = EV::signal_ns $signum, $callback
203 220
204=head1 BUGS 221=head1 BUGS
205 222
206Lots. 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
207is quite new at the moment. 224is quite new at the moment.
225
226Please note that the epoll method is not, in general, reliable in programs
227that use fork (even if no libveent calls are being made in the forked
228process). If your program behaves erratically, try setting the environment
229variable C<EVENT_NOEPOLL> first when running the program.
230
231In general, if you fork, then you can only use the EV module in one of the
232children.
208 233
209=cut 234=cut
210 235
211our $NPRI = 4; 236our $NPRI = 4;
212our $BASE = init; 237our $BASE = init;
213priority_init $NPRI; 238priority_init $NPRI;
214 239
240push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"];
241
2151; 2421;
243
244=head1 SEE ALSO
245
246 L<EV::DNS>, L<event(3)>, L<event.h>, L<evdns.h>.
247 L<EV::AnyEvent>.
216 248
217=head1 AUTHOR 249=head1 AUTHOR
218 250
219 Marc Lehmann <schmorp@schmorp.de> 251 Marc Lehmann <schmorp@schmorp.de>
220 http://home.schmorp.de/ 252 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines