diff options
| author | root <root> | 2009-07-15 16:58:53 +0000 | 
|---|---|---|
| committer | root <root> | 2009-07-15 16:58:53 +0000 | 
| commit | 5c8cc800f487e020d33cd08727c442b6a8067d9d (patch) | |
| tree | 96448386bbc5985c4bdd4e685abf06f27a89d401 | |
| parent | 2978dc2e820ccb62fe7f3b35a0672455e592017e (diff) | |
*** empty log message ***
| -rw-r--r-- | Changes | 11 | ||||
| -rw-r--r-- | ev.c | 6 | ||||
| -rw-r--r-- | ev.h | 2 | ||||
| -rw-r--r-- | ev.pod | 12 | 
4 files changed, 26 insertions, 5 deletions
| @@ -4,16 +4,18 @@ TODO: ev_walk  TODO: remain  TODO: EV_MINIMAL -        - new functionality: ev_set_userdata, ev_userdata, +	- ev_unloop and ev_loop wrongly used a global variable to exit loops, +          instead of using a per-loop variable (bug caught by accident...). +	- the ev_set_io_collect_interval interpretation has changed. +        - add new functionality: ev_set_userdata, ev_userdata,            ev_set_invoke_pending_cb, ev_set_loop_release_cb,            ev_invoke_pending, together with a long example about thread            locking. -	- ev_unloop and ev_loop wrongly used a global variable to exit loops, -          instead of using a per-loop variable (bug caught by accident...). +        - add ev_timer_remaining (as requested by Denis F. Latypoff). +        - add ev_loop_depth.          - calling ev_unloop in fork/prepare watchers will no longer poll            for new events.  	- Denis F. Latypoff corrected many typos in example code snippets. -	- the ev_set_io_collect_interval interpretation has changed.          - honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double-            check that the syscall number is available before trying to            use it (reported by ry@tinyclouds). @@ -21,7 +23,6 @@ TODO: EV_MINIMAL            slightly higher accuracy.          - properly declare ev_loop_verify and ev_now_update even when            !EV_MULTIPLICITY. -        - implement ev_loop_depth.          - do not compile in any priority code when EV_MAXPRI == EV_MINPRI.          - support EV_MINIMAL==2 for a reduced API.          - actually 0-initialise struct sigaction when installing signals. @@ -2489,6 +2489,12 @@ ev_timer_again (EV_P_ ev_timer *w)    EV_FREQUENT_CHECK;  } +ev_tstamp +ev_timer_remaining (EV_P_ ev_timer *w) +{ +  return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); +} +  #if EV_PERIODIC_ENABLE  void noinline  ev_periodic_start (EV_P_ ev_periodic *w) @@ -638,6 +638,8 @@ void ev_timer_start    (EV_P_ ev_timer *w);  void ev_timer_stop     (EV_P_ ev_timer *w);  /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */  void ev_timer_again    (EV_P_ ev_timer *w); +/* return remaining time */ +ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w);  #if EV_PERIODIC_ENABLE  void ev_periodic_start (EV_P_ ev_periodic *w); @@ -1822,6 +1822,18 @@ C<repeat> value), or reset the running timer to the C<repeat> value.  This sounds a bit complicated, see L<Be smart about timeouts>, above, for a  usage example. +=item ev_timer_remaining (loop, ev_timer *) + +Returns the remaining time until a timer fires. If the timer is active, +then this time is relative to the current event loop time, otherwise it's +the timeout value currently configured. + +That is, after an C<ev_timer_set (w, 5, 7)>, C<ev_timer_remaining> returns +C<5>. When the timer is started and one second passes, C<ev_timer_remain> +will return C<4>. When the timer expires and is restarted, it will return +roughly C<7> (likely slightly less as callback invocation takes some time, +too), and so on. +  =item ev_tstamp repeat [read-write]  The current C<repeat> value. Will be used each time the watcher times out | 
