MCPcopy Create free account
hub / github.com/apache/cloudberry / enable_timeout

Function enable_timeout

src/backend/utils/misc/timeout.c:156–194  ·  view source on GitHub ↗

* Enable the specified timeout reason */

Source from the content-addressed store, hash-verified

154 * Enable the specified timeout reason
155 */
156static void
157enable_timeout(TimeoutId id, TimestampTz now, TimestampTz fin_time)
158{
159 int i;
160
161 /* Assert request is sane */
162 Assert(all_timeouts_initialized);
163 Assert(all_timeouts[id].timeout_handler != NULL);
164
165 /*
166 * If this timeout was already active, momentarily disable it. We
167 * interpret the call as a directive to reschedule the timeout.
168 */
169 if (all_timeouts[id].active)
170 remove_timeout_index(find_active_timeout(id));
171
172 /*
173 * Find out the index where to insert the new timeout. We sort by
174 * fin_time, and for equal fin_time by priority.
175 */
176 for (i = 0; i < num_active_timeouts; i++)
177 {
178 timeout_params *old_timeout = active_timeouts[i];
179
180 if (fin_time < old_timeout->fin_time)
181 break;
182 if (fin_time == old_timeout->fin_time && id < old_timeout->index)
183 break;
184 }
185
186 /*
187 * Mark the timeout active, and insert it into the active list.
188 */
189 all_timeouts[id].indicator = false;
190 all_timeouts[id].start_time = now;
191 all_timeouts[id].fin_time = fin_time;
192
193 insert_timeout(id, i);
194}
195
196/*
197 * Schedule alarm for the next active timeout, if any

Callers 3

enable_timeout_afterFunction · 0.85
enable_timeout_atFunction · 0.85
enable_timeoutsFunction · 0.85

Calls 3

remove_timeout_indexFunction · 0.85
find_active_timeoutFunction · 0.85
insert_timeoutFunction · 0.85

Tested by

no test coverage detected