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.57 by root, Thu Apr 24 03:19:28 2008 UTC vs.
Revision 1.58 by root, Thu Apr 24 03:24:07 2008 UTC

207 207
208There 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
209in 10 seconds") and based on wallclock time (absolute, "fire at 12 209in 10 seconds") and based on wallclock time (absolute, "fire at 12
210o'clock"). 210o'clock").
211 211
212While 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
213absolute time internally. This makes a difference when your clock "jumps", 213use absolute time internally. This makes a difference when your clock
214for 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
2152008-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
216six years to finally fire. 216fire "after" a second might actually take six years to finally fire.
217 217
218AnyEvent cannot compensate for this. The only event loop that is conscious 218AnyEvent cannot compensate for this. The only event loop that is conscious
219about 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
220absolute (ev_periodic) timers. 220on true relative time) and absolute (ev_periodic, based on wallclock time)
221timers.
221 222
222AnyEvent always prefers relative timers, if available, matching the 223AnyEvent always prefers relative timers, if available, matching the
223AnyEvent API. 224AnyEvent API.
224 225
225=head2 SIGNAL WATCHERS 226=head2 SIGNAL WATCHERS
226 227
227You 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
228I<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
229be invoked whenever a signal occurs. 230be invoked whenever a signal occurs.
230 231
231Multiple signals occurances can be clumped together into one callback 232Multiple signal occurances can be clumped together into one callback
232invocation, and callback invocation will be synchronous. synchronous means 233invocation, and callback invocation will be synchronous. synchronous means
233that 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,
234but it is guarenteed not to interrupt any other callbacks. 235but it is guarenteed not to interrupt any other callbacks.
235 236
236The 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines