]>
Commit | Line | Data |
---|---|---|
2dcbb2a0 SW |
1 | #include "sends.h" |
2 | ||
3 | uint32_t next_send(send_t *s) { | |
4 | return s->timestamp + (1 << s->send_count) - 1; | |
5 | } | |
6 | ||
7 | bool next_send_less_than(void *user_data, pheap_node_id_t a, | |
8 | pheap_node_id_t b) { | |
9 | send_t *sends = (send_t *)user_data; | |
10 | return next_send(&sends[a]) < next_send(&sends[b]); | |
11 | } | |
67001c93 SW |
12 | |
13 | void create_send(send_t *sleeping_sends, pheap_t *sleeps_heap, | |
14 | uint32_t timestamp, u16_t seq) { | |
15 | pheap_node_id_t i = ph_new_node(sleeps_heap); | |
16 | if (i == 0) { | |
17 | /* TODO: Don't drop new presses just because sleeps_heap is full of old | |
18 | * presses. */ | |
19 | return; | |
20 | } | |
21 | sleeping_sends[i].timestamp = timestamp; | |
22 | sleeping_sends[i].seq = seq; | |
23 | sleeping_sends[i].send_count = 0; | |
24 | ph_insert_node(sleeps_heap, i); | |
25 | } |