… | |
… | |
1324 | year, it will still time out after (roughly) one hour. "Roughly" because |
1324 | year, it will still time out after (roughly) one hour. "Roughly" because |
1325 | detecting time jumps is hard, and some inaccuracies are unavoidable (the |
1325 | detecting time jumps is hard, and some inaccuracies are unavoidable (the |
1326 | monotonic clock option helps a lot here). |
1326 | monotonic clock option helps a lot here). |
1327 | |
1327 | |
1328 | The callback is guaranteed to be invoked only I<after> its timeout has |
1328 | The callback is guaranteed to be invoked only I<after> its timeout has |
1329 | passed, but if multiple timers become ready during the same loop iteration |
1329 | passed. If multiple timers become ready during the same loop iteration |
1330 | then order of execution is undefined. |
1330 | then the ones with earlier time-out values are invoked before ones with |
|
|
1331 | later time-out values (but this is no longer true when a callback calls |
|
|
1332 | C<ev_loop> recursively). |
1331 | |
1333 | |
1332 | =head3 Be smart about timeouts |
1334 | =head3 Be smart about timeouts |
1333 | |
1335 | |
1334 | Many real-world problems involve some kind of timeout, usually for error |
1336 | Many real-world problems involve some kind of timeout, usually for error |
1335 | recovery. A typical example is an HTTP request - if the other side hangs, |
1337 | recovery. A typical example is an HTTP request - if the other side hangs, |
… | |
… | |
1624 | timers, such as triggering an event on each "midnight, local time", or |
1626 | timers, such as triggering an event on each "midnight, local time", or |
1625 | other complicated rules. This cannot be done with C<ev_timer> watchers, as |
1627 | other complicated rules. This cannot be done with C<ev_timer> watchers, as |
1626 | those cannot react to time jumps. |
1628 | those cannot react to time jumps. |
1627 | |
1629 | |
1628 | As with timers, the callback is guaranteed to be invoked only when the |
1630 | As with timers, the callback is guaranteed to be invoked only when the |
1629 | point in time where it is supposed to trigger has passed, but if multiple |
1631 | point in time where it is supposed to trigger has passed. If multiple |
1630 | periodic timers become ready during the same loop iteration, then order of |
1632 | timers become ready during the same loop iteration then the ones with |
1631 | execution is undefined. |
1633 | earlier time-out values are invoked before ones with later time-out values |
|
|
1634 | (but this is no longer true when a callback calls C<ev_loop> recursively). |
1632 | |
1635 | |
1633 | =head3 Watcher-Specific Functions and Data Members |
1636 | =head3 Watcher-Specific Functions and Data Members |
1634 | |
1637 | |
1635 | =over 4 |
1638 | =over 4 |
1636 | |
1639 | |