From ee09c6482709ae9fe8de8dabf7c726b8e35f33eb Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 28 Jul 2010 22:28:54 +0200 Subject: [PATCH] Main: Added timer_add_rel() --- ucw/mainloop.c | 11 +++++++++-- ucw/mainloop.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ucw/mainloop.c b/ucw/mainloop.c index 2b261870..77eb8d9e 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -173,6 +173,13 @@ timer_add(struct main_timer *tm, timestamp_t expires) } } +void +timer_add_rel(struct main_timer *tm, timestamp_t expires_delta) +{ + struct main_context *m = main_current(); + return timer_add(tm, m->now + expires_delta); +} + void timer_del(struct main_timer *tm) { @@ -666,7 +673,7 @@ static int dhook(struct main_hook *ho UNUSED) static void dtimer(struct main_timer *tm) { msg(L_INFO, "Timer tick"); - timer_add(tm, main_get_now() + 10000); + timer_add_rel(tm, 10000); } static void dentry(void) @@ -704,7 +711,7 @@ main(void) hook_add(&hook); tm.handler = dtimer; - timer_add(&tm, main_get_now() + 1000); + timer_add_rel(&tm, 1000); mp.handler = dexit; if (!process_fork(&mp)) diff --git a/ucw/mainloop.h b/ucw/mainloop.h index 0de1f702..efbabcb4 100644 --- a/ucw/mainloop.h +++ b/ucw/mainloop.h @@ -119,6 +119,9 @@ struct main_timer { * The @expire parameter is absolute, just add <> if you need a relative timer. **/ void timer_add(struct main_timer *tm, timestamp_t expires); + +void timer_add_rel(struct main_timer *tm, timestamp_t expires_delta); + /** * Removes a timer from the active ones. It is permitted (and usual) to call * this function from the timer's handler itself if you want to deactivate -- 2.39.2