uloop: add uloop_timeout_pending() function to determine the remaining time of an active timeout
This commit is contained in:
parent
e009fd8c82
commit
77984bd24d
2 changed files with 13 additions and 0 deletions
12
uloop.c
12
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;
|
||||
|
|
1
uloop.h
1
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);
|
||||
|
|
Loading…
Reference in a new issue