diff --git a/uloop.c b/uloop.c index 769b6c5..0134fa4 100644 --- a/uloop.c +++ b/uloop.c @@ -338,6 +338,18 @@ int uloop_timeout_remaining(struct uloop_timeout *timeout) return (int)td; } +int64_t uloop_timeout_remaining64(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 36084f5..7ac345e 100644 --- a/uloop.h +++ b/uloop.h @@ -93,6 +93,7 @@ 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_remaining(struct uloop_timeout *timeout); +int64_t uloop_timeout_remaining64(struct uloop_timeout *timeout); int uloop_process_add(struct uloop_process *p); int uloop_process_delete(struct uloop_process *p);