… | |
… | |
1197 | times out after an hour and you reset your system clock to January last |
1197 | times out after an hour and you reset your system clock to January last |
1198 | year, it will still time out after (roughly) and hour. "Roughly" because |
1198 | year, it will still time out after (roughly) and hour. "Roughly" because |
1199 | detecting time jumps is hard, and some inaccuracies are unavoidable (the |
1199 | detecting time jumps is hard, and some inaccuracies are unavoidable (the |
1200 | monotonic clock option helps a lot here). |
1200 | monotonic clock option helps a lot here). |
1201 | |
1201 | |
|
|
1202 | The callback is guaranteed to be invoked only after its timeout has passed, |
|
|
1203 | but if multiple timers become ready during the same loop iteration then |
|
|
1204 | order of execution is undefined. |
|
|
1205 | |
|
|
1206 | =head3 The special problem of time updates |
|
|
1207 | |
|
|
1208 | Requesting the current time is a costly operation (it usually takes at |
|
|
1209 | least two syscalls): EV therefore updates it's idea of the current time |
|
|
1210 | only before and after C<ev_loop> polls for new events, which causes the |
|
|
1211 | difference between C<ev_now ()> and C<ev_time ()>. |
|
|
1212 | |
1202 | The relative timeouts are calculated relative to the C<ev_now ()> |
1213 | The relative timeouts are calculated relative to the C<ev_now ()> |
1203 | time. This is usually the right thing as this timestamp refers to the time |
1214 | time. This is usually the right thing as this timestamp refers to the time |
1204 | of the event triggering whatever timeout you are modifying/starting. If |
1215 | of the event triggering whatever timeout you are modifying/starting. If |
1205 | you suspect event processing to be delayed and you I<need> to base the timeout |
1216 | you suspect event processing to be delayed and you I<need> to base the |
1206 | on the current time, use something like this to adjust for this: |
1217 | timeout on the current time, use something like this to adjust for this: |
1207 | |
1218 | |
1208 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
1219 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
1209 | |
|
|
1210 | The callback is guaranteed to be invoked only after its timeout has passed, |
|
|
1211 | but if multiple timers become ready during the same loop iteration then |
|
|
1212 | order of execution is undefined. |
|
|
1213 | |
1220 | |
1214 | =head3 Watcher-Specific Functions and Data Members |
1221 | =head3 Watcher-Specific Functions and Data Members |
1215 | |
1222 | |
1216 | =over 4 |
1223 | =over 4 |
1217 | |
1224 | |