mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
daemon: timeout structure for IO.
For better or worse, the ccan/timer structure is completely minimal, and designed to be wrapped inside a container structure. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
18
daemon/timeout.c
Normal file
18
daemon/timeout.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "lightningd.h"
|
||||
#include "timeout.h"
|
||||
|
||||
void init_timeout_(struct timeout *t, unsigned int interval,
|
||||
void (*cb)(void *), void *arg)
|
||||
{
|
||||
timer_init(&t->timer);
|
||||
t->interval = time_from_sec(interval);
|
||||
t->cb = cb;
|
||||
t->arg = arg;
|
||||
}
|
||||
|
||||
void refresh_timeout(struct lightningd_state *state, struct timeout *t)
|
||||
{
|
||||
timer_del(&state->timers, &t->timer);
|
||||
timer_add(&state->timers, &t->timer,
|
||||
timeabs_add(time_now(), t->interval));
|
||||
}
|
||||
Reference in New Issue
Block a user