lib: add function to get precise remaining time of timer thread

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Christian Franke 2015-11-10 18:04:41 +01:00 committed by Donald Sharp
parent f3d2b2813d
commit 6ac446878f
2 changed files with 9 additions and 0 deletions

View File

@ -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,

View File

@ -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 */