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

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.56 by root, Thu Apr 24 03:10:03 2008 UTC vs.
Revision 1.59 by root, Thu Apr 24 08:38:13 2008 UTC

78 78
79The interface itself is vaguely similar, but not identical to the L<Event> 79The interface itself is vaguely similar, but not identical to the L<Event>
80module. 80module.
81 81
82During the first call of any watcher-creation method, the module tries 82During the first call of any watcher-creation method, the module tries
83to detect the currently loaded event loop by probing whether one of the 83to detect the currently loaded event loop by probing whether one of
84following modules is already loaded: L<Coro::EV>, L<Coro::Event>, L<EV>, 84the following modules is already loaded: L<Coro::EV>, L<Coro::Event>,
85L<Event>, L<Glib>, L<Tk>. The first one found is used. If none are found, 85L<EV>, L<Event>, L<Glib>, L<Tk>, L<Event::Lib>, L<Qt>. The first one
86the module tries to load these modules in the stated order. The first one 86found is used. If none are found, the module tries to load these modules
87(excluding Event::Lib and Qt) in the order given. The first one that can
87that can be successfully loaded will be used. If, after this, still none 88be successfully loaded will be used. If, after this, still none could be
88could be found, AnyEvent will fall back to a pure-perl event loop, which 89found, AnyEvent will fall back to a pure-perl event loop, which is not
89is not very efficient, but should work everywhere. 90very efficient, but should work everywhere.
90 91
91Because AnyEvent first checks for modules that are already loaded, loading 92Because AnyEvent first checks for modules that are already loaded, loading
92an event model explicitly before first using AnyEvent will likely make 93an event model explicitly before first using AnyEvent will likely make
93that model the default. For example: 94that model the default. For example:
94 95
206 207
207There are two ways to handle timers: based on real time (relative, "fire 208There are two ways to handle timers: based on real time (relative, "fire
208in 10 seconds") and based on wallclock time (absolute, "fire at 12 209in 10 seconds") and based on wallclock time (absolute, "fire at 12
209o'clock"). 210o'clock").
210 211
211While most event loops expect timers to specified in a relative way, they use 212While most event loops expect timers to specified in a relative way, they
212absolute time internally. This makes a difference when your clock "jumps", 213use absolute time internally. This makes a difference when your clock
213for example, when ntp decides to set your clock backwards from the wrong 2014-01-01 to 214"jumps", for example, when ntp decides to set your clock backwards from
2142008-01-01, a watcher that you created to fire "after" a second might actually take 215the wrong date of 2014-01-01 to 2008-01-01, a watcher that is supposed to
215six years to finally fire. 216fire "after" a second might actually take six years to finally fire.
216 217
217AnyEvent cannot compensate for this. The only event loop that is conscious 218AnyEvent cannot compensate for this. The only event loop that is conscious
218about these issues is L<EV>, which offers both relative (ev_timer) and 219about these issues is L<EV>, which offers both relative (ev_timer, based
219absolute (ev_periodic) timers. 220on true relative time) and absolute (ev_periodic, based on wallclock time)
221timers.
220 222
221AnyEvent always prefers relative timers, if available, matching the 223AnyEvent always prefers relative timers, if available, matching the
222AnyEvent API. 224AnyEvent API.
223 225
224=head2 SIGNAL WATCHERS 226=head2 SIGNAL WATCHERS
225 227
226You can watch for signals using a signal watcher, C<signal> is the signal 228You can watch for signals using a signal watcher, C<signal> is the signal
227I<name> without any C<SIG> prefix, C<cb> is the Perl callback to 229I<name> without any C<SIG> prefix, C<cb> is the Perl callback to
228be invoked whenever a signal occurs. 230be invoked whenever a signal occurs.
229 231
230Multiple signals occurances can be clumped together into one callback 232Multiple signal occurances can be clumped together into one callback
231invocation, and callback invocation will be synchronous. synchronous means 233invocation, and callback invocation will be synchronous. synchronous means
232that it might take a while until the signal gets handled by the process, 234that it might take a while until the signal gets handled by the process,
233but it is guarenteed not to interrupt any other callbacks. 235but it is guarenteed not to interrupt any other callbacks.
234 236
235The main advantage of using these watchers is that you can share a signal 237The main advantage of using these watchers is that you can share a signal
420no warnings; 422no warnings;
421use strict; 423use strict;
422 424
423use Carp; 425use Carp;
424 426
425our $VERSION = '3.12'; 427our $VERSION = '3.2';
426our $MODEL; 428our $MODEL;
427 429
428our $AUTOLOAD; 430our $AUTOLOAD;
429our @ISA; 431our @ISA;
430 432

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines