mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
common: add routine for absolute timeouts (vs. relative).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e37a638c0c
commit
1f608acd4e
@ -31,7 +31,24 @@ struct oneshot *new_reltimer_(struct timers *timers,
|
||||
return t;
|
||||
}
|
||||
|
||||
void *reltimer_arg(struct oneshot *t)
|
||||
struct oneshot *new_abstimer_(struct timers *timers,
|
||||
const tal_t *ctx,
|
||||
struct timemono expiry,
|
||||
void (*cb)(void *), void *arg)
|
||||
{
|
||||
struct oneshot *t = tal(ctx, struct oneshot);
|
||||
|
||||
t->cb = cb;
|
||||
t->arg = arg;
|
||||
t->timers = timers;
|
||||
timer_init(&t->timer);
|
||||
timer_addmono(timers, &t->timer, expiry);
|
||||
tal_add_destructor(t, destroy_timer);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void *oneshot_arg(struct oneshot *t)
|
||||
{
|
||||
return t->arg;
|
||||
}
|
||||
|
@ -15,8 +15,16 @@ struct oneshot *new_reltimer_(struct timers *timers,
|
||||
new_reltimer_((timers), (ctx), (relexpire), \
|
||||
typesafe_cb(void, void *, (func), (arg)), (arg))
|
||||
|
||||
struct oneshot *new_abstimer_(struct timers *timers,
|
||||
const tal_t *ctx,
|
||||
struct timemono expiry,
|
||||
void (*cb)(void *), void *arg);
|
||||
#define new_abstimer(timers, ctx, expiry, func, arg) \
|
||||
new_abstimer_((timers), (ctx), (expiry), \
|
||||
typesafe_cb(void, void *, (func), (arg)), (arg))
|
||||
|
||||
/* Get timer arg. */
|
||||
void *reltimer_arg(struct oneshot *t);
|
||||
void *oneshot_arg(struct oneshot *t);
|
||||
|
||||
void timer_expired(struct timer *timer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user