From: Christian Franke Date: Tue, 10 Nov 2015 17:04:41 +0000 (+0100) Subject: lib: add function to get precise remaining time of timer thread X-Git-Tag: frr-2.0-rc1~1013 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=6ac446878fe25f3f34f856c3daff4e4021b8b70c;p=mirror%2Ffrr.git lib: add function to get precise remaining time of timer thread Signed-off-by: Christian Franke Acked-by: Donald Sharp --- diff --git a/lib/thread.c b/lib/thread.c index c56a9ec505..ab4764dfb1 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -766,6 +766,14 @@ strip_funcname (char *dest, const char *funcname) *e = tmp; } +struct timeval +thread_timer_remain(struct thread *thread) +{ + quagga_get_relative(NULL); + + return timeval_subtract(thread->u.sands, relative_time); +} + /* Get new thread. */ static struct thread * thread_get (struct thread_master *m, u_char type, diff --git a/lib/thread.h b/lib/thread.h index c8c8c19323..4ca1e3ce04 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -235,6 +235,7 @@ extern unsigned int thread_cancel_event (struct thread_master *, void *); extern struct thread *thread_fetch (struct thread_master *, struct thread *); extern void thread_call (struct thread *); extern unsigned long thread_timer_remain_second (struct thread *); +extern struct timeval thread_timer_remain(struct thread*); extern int thread_should_yield (struct thread *); extern unsigned long timeval_elapsed (struct timeval a, struct timeval b); /* set yield time for thread */