… | |
… | |
572 | Returns the current "event loop time", which is the time the event loop |
572 | Returns the current "event loop time", which is the time the event loop |
573 | received events and started processing them. This timestamp does not |
573 | received events and started processing them. This timestamp does not |
574 | change as long as callbacks are being processed, and this is also the base |
574 | change as long as callbacks are being processed, and this is also the base |
575 | time used for relative timers. You can treat it as the timestamp of the |
575 | time used for relative timers. You can treat it as the timestamp of the |
576 | event occurring (or more correctly, libev finding out about it). |
576 | event occurring (or more correctly, libev finding out about it). |
|
|
577 | |
|
|
578 | =item ev_now_update (loop) |
|
|
579 | |
|
|
580 | Establishes the current time by querying the kernel, updating the time |
|
|
581 | returned by C<ev_now ()> in the progress. This is a costly operation and |
|
|
582 | is usually done automatically within C<ev_loop ()>. |
|
|
583 | |
|
|
584 | This function is rarely useful, but when some event callback runs for a |
|
|
585 | very long time without entering the event loop, updating libev's idea of |
|
|
586 | the current time is a good idea. |
|
|
587 | |
|
|
588 | See also "The special problem of time updates" in the C<ev_timer> section. |
577 | |
589 | |
578 | =item ev_loop (loop, int flags) |
590 | =item ev_loop (loop, int flags) |
579 | |
591 | |
580 | Finally, this is it, the event handler. This function usually is called |
592 | Finally, this is it, the event handler. This function usually is called |
581 | after you initialised all your watchers and you want to start handling |
593 | after you initialised all your watchers and you want to start handling |
… | |
… | |
1203 | but if multiple timers become ready during the same loop iteration then |
1215 | but if multiple timers become ready during the same loop iteration then |
1204 | order of execution is undefined. |
1216 | order of execution is undefined. |
1205 | |
1217 | |
1206 | =head3 The special problem of time updates |
1218 | =head3 The special problem of time updates |
1207 | |
1219 | |
1208 | Requesting the current time is a costly operation (it usually takes at |
1220 | Establishing 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 |
1221 | least two system calls): EV therefore updates its idea of the current |
1210 | only before and after C<ev_loop> polls for new events, which causes the |
1222 | time only before and after C<ev_loop> polls for new events, which causes |
1211 | difference between C<ev_now ()> and C<ev_time ()>. |
1223 | a growing difference between C<ev_now ()> and C<ev_time ()> when handling |
|
|
1224 | lots of events. |
1212 | |
1225 | |
1213 | The relative timeouts are calculated relative to the C<ev_now ()> |
1226 | The relative timeouts are calculated relative to the C<ev_now ()> |
1214 | time. This is usually the right thing as this timestamp refers to the time |
1227 | time. This is usually the right thing as this timestamp refers to the time |
1215 | of the event triggering whatever timeout you are modifying/starting. If |
1228 | of the event triggering whatever timeout you are modifying/starting. If |
1216 | you suspect event processing to be delayed and you I<need> to base the |
1229 | you suspect event processing to be delayed and you I<need> to base the |
1217 | timeout on the current time, use something like this to adjust for this: |
1230 | timeout on the current time, use something like this to adjust for this: |
1218 | |
1231 | |
1219 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
1232 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
|
|
1233 | |
|
|
1234 | If the event loop is suspended for a long time, one can also force an |
|
|
1235 | update of the time returned by C<ev_now ()> by calling C<ev_now_update |
|
|
1236 | ()>. |
1220 | |
1237 | |
1221 | =head3 Watcher-Specific Functions and Data Members |
1238 | =head3 Watcher-Specific Functions and Data Members |
1222 | |
1239 | |
1223 | =over 4 |
1240 | =over 4 |
1224 | |
1241 | |