ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.381 by root, Sat Aug 13 17:41:14 2011 UTC vs.
Revision 1.382 by sf-exg, Mon Aug 15 10:18:07 2011 UTC

1961cannot be guaranteed to infinite precision. Less obviously, it cannot be 1961cannot be guaranteed to infinite precision. Less obviously, it cannot be
1962guaranteed to any precision by libev - imagine somebody suspending the 1962guaranteed to any precision by libev - imagine somebody suspending the
1963process a STOP signal for a few hours for example. 1963process a STOP signal for a few hours for example.
1964 1964
1965So, libev tries to invoke your callback as soon as possible I<after> the 1965So, libev tries to invoke your callback as soon as possible I<after> the
1966delay has occured, but cannot guarantee this. 1966delay has occurred, but cannot guarantee this.
1967 1967
1968A less obvious failure mode is calling your callback too early: many event 1968A less obvious failure mode is calling your callback too early: many event
1969loops compare timestamps with a "elapsed delay >= requested delay", but 1969loops compare timestamps with a "elapsed delay >= requested delay", but
1970this can cause your callback to be invoked much earlier than you would 1970this can cause your callback to be invoked much earlier than you would
1971expect. 1971expect.
2023a call to C<gettimeofday> might return a second count that is one higher 2023a call to C<gettimeofday> might return a second count that is one higher
2024than a directly following call to C<time>. 2024than a directly following call to C<time>.
2025 2025
2026The moral of this is to only compare libev-related timestamps with 2026The moral of this is to only compare libev-related timestamps with
2027C<ev_time ()> and C<ev_now ()>, at least if you want better precision than 2027C<ev_time ()> and C<ev_now ()>, at least if you want better precision than
2028a seocnd or so. 2028a second or so.
2029 2029
2030One more problem arises due to this lack of synchronisation: if libev uses 2030One more problem arises due to this lack of synchronisation: if libev uses
2031the system monotonic clock and you compare timestamps from C<ev_time> 2031the system monotonic clock and you compare timestamps from C<ev_time>
2032or C<ev_now> from when you started your timer and when your callback is 2032or C<ev_now> from when you started your timer and when your callback is
2033invoked, you will find that sometimes the callback is a bit "early". 2033invoked, you will find that sometimes the callback is a bit "early".
5132good enough for at least into the year 4000 with millisecond accuracy 5132good enough for at least into the year 4000 with millisecond accuracy
5133(the design goal for libev). This requirement is overfulfilled by 5133(the design goal for libev). This requirement is overfulfilled by
5134implementations using IEEE 754, which is basically all existing ones. 5134implementations using IEEE 754, which is basically all existing ones.
5135 5135
5136With IEEE 754 doubles, you get microsecond accuracy until at least the 5136With IEEE 754 doubles, you get microsecond accuracy until at least the
5137year 2255 (and millisecond accuray till the year 287396 - by then, libev 5137year 2255 (and millisecond accuracy till the year 287396 - by then, libev
5138is either obsolete or somebody patched it to use C<long double> or 5138is either obsolete or somebody patched it to use C<long double> or
5139something like that, just kidding). 5139something like that, just kidding).
5140 5140
5141=back 5141=back
5142 5142

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines