| 36 | } |
| 37 | |
| 38 | static int timer_queue_insert(struct timer_queue *tq, |
| 39 | struct timeout_callback *tocb) |
| 40 | { |
| 41 | int index; |
| 42 | |
| 43 | /* No more slots. */ |
| 44 | if (timer_queue_full(tq)) |
| 45 | return -1; |
| 46 | |
| 47 | index = tq->num_entries; |
| 48 | tq->num_entries++; |
| 49 | tq->queue[index] = tocb; |
| 50 | |
| 51 | while (index != 0) { |
| 52 | struct timeout_callback *parent; |
| 53 | int parent_index; |
| 54 | |
| 55 | parent_index = (index - 1) / 2; |
| 56 | parent = tq->queue[parent_index]; |
| 57 | |
| 58 | /* All other ancestors are less than or equal to the current. */ |
| 59 | if (mono_time_cmp(&parent->expiration, &tocb->expiration) <= 0) |
| 60 | break; |
| 61 | |
| 62 | /* The parent is greater than current. Swap them. */ |
| 63 | tq->queue[parent_index] = tocb; |
| 64 | tq->queue[index] = parent; |
| 65 | |
| 66 | index = parent_index; |
| 67 | } |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | /* Get the index containing the entry with smallest value. */ |
| 73 | static int timer_queue_min_child_index(struct timer_queue *tq, int index) |
no test coverage detected