summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-10-31 11:52:12 +0000
committerroot <root>2007-10-31 11:52:12 +0000
commit19d6e7a1f1a0ef5dcde45cc8c0d175129c73cfe1 (patch)
tree8fb237ed1f57d56c11e6ddebcd90ccc28b491686
parent487c8aa2bb79f45c17a479dd48d8dc45948d2527 (diff)
*** empty log message ***
-rw-r--r--ev.c21
-rw-r--r--ev.h1
2 files changed, 21 insertions, 1 deletions
diff --git a/ev.c b/ev.c
index a038613..96380ac 100644
--- a/ev.c
+++ b/ev.c
@@ -540,7 +540,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,10 +679,29 @@ 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)
{
if (ev_is_active (w))
diff --git a/ev.h b/ev.h
index 7236712..e4de49b 100644
--- a/ev.h
+++ b/ev.h
@@ -146,6 +146,7 @@ void evio_stop (struct ev_io *w);
void evtimer_start (struct ev_timer *w);
void evtimer_stop (struct ev_timer *w);
+void evtimer_again (struct ev_timer *w); /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
void evperiodic_start (struct ev_periodic *w);
void evperiodic_stop (struct ev_periodic *w);