X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/487c8aa2bb79f45c17a479dd48d8dc45948d2527..49a82c163f76e2916974ec3eac8d395662e7187b:/ev.c?ds=inline diff --git a/ev.c b/ev.c index a038613..aefc9df 100644 --- a/ev.c +++ b/ev.c @@ -85,7 +85,6 @@ get_clock (void) if ((cnt) > cur) \ { \ int newcnt = cur ? cur << 1 : 16; \ - fprintf (stderr, "resize(" # base ") from %d to %d\n", cur, newcnt);\ base = realloc (base, sizeof (*base) * (newcnt)); \ init (base + cur, newcnt - cur); \ cur = newcnt; \ @@ -540,7 +539,7 @@ void ev_loop (int flags) if (timercnt) { - ev_tstamp to = timers [0]->at - get_clock () + method_fudge; + ev_tstamp to = timers [0]->at - (have_monotonic ? get_clock () : ev_now) + method_fudge; if (block > to) block = to; } @@ -679,9 +678,28 @@ evtimer_stop (struct ev_timer *w) downheap ((WT *)timers, timercnt, w->active - 1); } + w->at = w->repeat; + ev_stop ((W)w); } +void +evtimer_again (struct ev_timer *w) +{ + if (ev_is_active (w)) + { + if (w->repeat) + { + w->at = now + w->repeat; + downheap ((WT *)timers, timercnt, w->active - 1); + } + else + evtimer_stop (w); + } + else if (w->repeat) + evtimer_start (w); +} + void evperiodic_start (struct ev_periodic *w) {