blob: 7fc45194ee27d2c04ef0ba28443d045640994d54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
typedef s64 xxx_time;
typedef struct timer
{
resource r;
void (*hook)(struct timer2 *);
void *data;
xxx_time expires; /* 0=inactive */
unsigned randomize; /* Amount of randomization */
unsigned recurrent; /* Timer recurrence */
int index;
} timer;
void ev2_schedule(event *e);
timer2 *tm2_new(pool *p);
void tm2_start(timer2 *t, xxx_time after);
void tm2_stop(timer2 *t);
static inline xxx_time
tm2_remains(timer2 *t)
{
return (t->expires > xxxnow) ? t->expires - xxxnow : 0;
}
static inline void
tm2_start_max(timer2 *t, xxx_time after)
{
xxx_time rem = tm2_remains(t);
tm2_start(t, MAX(rem, after));
}
static inline timer2 *
tm2_new_set(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint rand)
{
timer2 *t = tm2_new(p);
t->hook = hook;
t->data = data;
t->recurrent = rec;
t->randomize = rand;
return t;
}
void sk_start(sock *s);
void sk_stop(sock *s);
struct birdloop *birdloop_new(pool *p);
void birdloop_enter(struct birdloop *loop);
void birdloop_leave(struct birdloop *loop);
void birdloop_main(struct birdloop *loop);
|