* Insert specified timeout reason into the list of active timeouts * at the given index. */
| 110 | * at the given index. |
| 111 | */ |
| 112 | static void |
| 113 | insert_timeout(TimeoutId id, int index) |
| 114 | { |
| 115 | int i; |
| 116 | |
| 117 | if (index < 0 || index > num_active_timeouts) |
| 118 | elog(FATAL, "timeout index %d out of range 0..%d", index, |
| 119 | num_active_timeouts); |
| 120 | |
| 121 | Assert(!all_timeouts[id].active); |
| 122 | all_timeouts[id].active = true; |
| 123 | |
| 124 | for (i = num_active_timeouts - 1; i >= index; i--) |
| 125 | active_timeouts[i + 1] = active_timeouts[i]; |
| 126 | |
| 127 | active_timeouts[index] = &all_timeouts[id]; |
| 128 | |
| 129 | num_active_timeouts++; |
| 130 | } |
| 131 | |
| 132 | /* |
| 133 | * Remove the index'th element from the timeout list. |