summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2009-04-15 19:35:53 +0000
committerroot <root>2009-04-15 19:35:53 +0000
commitfccdbf50f2094e18861bcb38d5b980212d04c242 (patch)
tree766db4c23eca458f17cca74ea6868ea2215c39a4 /ev.c
parent884a0a8e027cf993c05195afd00d0a9e8078417a (diff)
resume/suspend
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c79
1 files changed, 52 insertions, 27 deletions
diff --git a/ev.c b/ev.c
index 10b684c..410805e 100644
--- a/ev.c
+++ b/ev.c
@@ -1898,6 +1898,19 @@ periodics_reschedule (EV_P)
}
#endif
+static void noinline
+timers_reschedule (EV_P_ ev_tstamp adjust)
+{
+ int i;
+
+ for (i = 0; i < timercnt; ++i)
+ {
+ ANHE *he = timers + i + HEAP0;
+ ANHE_w (*he)->at += adjust;
+ ANHE_at_cache (*he);
+ }
+}
+
inline_speed void
time_update (EV_P_ ev_tstamp max_block)
{
@@ -1941,11 +1954,11 @@ time_update (EV_P_ ev_tstamp max_block)
now_floor = mn_now;
}
+ /* no timer adjustment, as the monotonic clock doesn't jump */
+ /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
# if EV_PERIODIC_ENABLE
periodics_reschedule (EV_A);
# endif
- /* no timer adjustment, as the monotonic clock doesn't jump */
- /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
}
else
#endif
@@ -1954,40 +1967,17 @@ time_update (EV_P_ ev_tstamp max_block)
if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP))
{
+ /* adjust timers. this is easy, as the offset is the same for all of them */
+ timers_reschedule (EV_A_ ev_rt_now - mn_now);
#if EV_PERIODIC_ENABLE
periodics_reschedule (EV_A);
#endif
- /* adjust timers. this is easy, as the offset is the same for all of them */
- for (i = 0; i < timercnt; ++i)
- {
- ANHE *he = timers + i + HEAP0;
- ANHE_w (*he)->at += ev_rt_now - mn_now;
- ANHE_at_cache (*he);
- }
}
mn_now = ev_rt_now;
}
}
-void
-ev_ref (EV_P)
-{
- ++activecnt;
-}
-
-void
-ev_unref (EV_P)
-{
- --activecnt;
-}
-
-void
-ev_now_update (EV_P)
-{
- time_update (EV_A_ 1e100);
-}
-
static int loop_done;
void
@@ -2115,6 +2105,41 @@ ev_unloop (EV_P_ int how)
loop_done = how;
}
+void
+ev_ref (EV_P)
+{
+ ++activecnt;
+}
+
+void
+ev_unref (EV_P)
+{
+ --activecnt;
+}
+
+void
+ev_now_update (EV_P)
+{
+ time_update (EV_A_ 1e100);
+}
+
+void
+ev_suspend (EV_P)
+{
+ ev_now_update (EV_A);
+}
+
+void
+ev_resume (EV_P)
+{
+ ev_tstamp mn_prev = mn_now;
+
+ ev_now_update (EV_A);
+ printf ("update %f\n", mn_now - mn_prev);//D
+ timers_reschedule (EV_A_ mn_now - mn_prev);
+ periodics_reschedule (EV_A);
+}
+
/*****************************************************************************/
inline_size void