From: Jo-Philipp Wich Date: Tue, 22 Jan 2013 14:50:09 +0000 (+0100) Subject: uloop: add uloop_timeout_pending() function to determine the remaining time of an... X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=77984bd24d0daa1e6ce7836a31c2b500621af99b;p=oweals%2Flibubox.git uloop: add uloop_timeout_pending() function to determine the remaining time of an active timeout --- diff --git a/uloop.c b/uloop.c index 4095d5b..3a62b62 100644 --- a/uloop.c +++ b/uloop.c @@ -387,6 +387,18 @@ int uloop_timeout_cancel(struct uloop_timeout *timeout) return 0; } +int uloop_timeout_pending(struct uloop_timeout *timeout) +{ + struct timeval now; + + if (!timeout->pending) + return -1; + + uloop_gettime(&now); + + return tv_diff(&timeout->time, &now); +} + int uloop_process_add(struct uloop_process *p) { struct uloop_process *tmp; diff --git a/uloop.h b/uloop.h index 0a20eb9..8fb890d 100644 --- a/uloop.h +++ b/uloop.h @@ -87,6 +87,7 @@ int uloop_fd_delete(struct uloop_fd *sock); int uloop_timeout_add(struct uloop_timeout *timeout); int uloop_timeout_set(struct uloop_timeout *timeout, int msecs); int uloop_timeout_cancel(struct uloop_timeout *timeout); +int uloop_timeout_pending(struct uloop_timeout *timeout); int uloop_process_add(struct uloop_process *p); int uloop_process_delete(struct uloop_process *p);