]> mj.ucw.cz Git - libucw.git/commitdiff
Main: Added timer_add_rel()
authorMartin Mares <mj@ucw.cz>
Wed, 28 Jul 2010 20:28:54 +0000 (22:28 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 18 Aug 2010 16:12:57 +0000 (18:12 +0200)
ucw/mainloop.c
ucw/mainloop.h

index 2b2618707915fc9502bb5e5f6356703704b17bcb..77eb8d9e8bacec58587bd3d7826dd28dffe59056 100644 (file)
@@ -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))
index 0de1f70231fa09d6b1df2d9515fe09c8927def74..efbabcb46e42ccd820319ae3aa7ac60ea7501cfb 100644 (file)
@@ -119,6 +119,9 @@ struct main_timer {
  * The @expire parameter is absolute, just add <<var_main_now,`main_now`>> 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