2
* BIRD -- I/O and event loop
4
* Can be freely distributed and used under the terms of the GNU GPL.
7
#ifndef _BIRD_BFD_IO_H_
8
#define _BIRD_BFD_IO_H_
10
#include "nest/bird.h"
11
#include "lib/lists.h"
12
#include "lib/resource.h"
13
#include "lib/event.h"
14
#include "lib/socket.h"
15
// #include "lib/timer.h"
21
void (*hook)(struct timer2 *);
24
btime expires; /* 0=inactive */
25
uint randomize; /* Amount of randomization */
26
uint recurrent; /* Timer recurrence */
32
btime current_time(void);
34
void ev2_schedule(event *e);
37
timer2 *tm2_new(pool *p);
38
void tm2_set(timer2 *t, btime when);
39
void tm2_start(timer2 *t, btime after);
40
void tm2_stop(timer2 *t);
45
return t->expires != 0;
49
tm2_remains(timer2 *t)
51
btime now = current_time();
52
return (t->expires > now) ? (t->expires - now) : 0;
55
static inline timer2 *
56
tm2_new_init(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint rand)
58
timer2 *t = tm2_new(p);
67
tm2_set_max(timer2 *t, btime when)
69
if (when > t->expires)
75
tm2_start_max(timer2 *t, btime after)
77
btime rem = tm2_remains(t);
78
tm2_start(t, MAX_(rem, after));
83
void sk_start(sock *s);
84
void sk_stop(sock *s);
88
struct birdloop *birdloop_new(void);
89
void birdloop_start(struct birdloop *loop);
90
void birdloop_stop(struct birdloop *loop);
91
void birdloop_free(struct birdloop *loop);
93
void birdloop_enter(struct birdloop *loop);
94
void birdloop_leave(struct birdloop *loop);
95
void birdloop_mask_wakeups(struct birdloop *loop);
96
void birdloop_unmask_wakeups(struct birdloop *loop);
99
#endif /* _BIRD_BFD_IO_H_ */