Skip to content

Commit 265615e

Browse files
joevtdingusdev
authored andcommitted
timermanager: Make sure the correct timer is popped.
Pop using the ID just in case some other thread pushes a timer with higher priority to the priority queue.
1 parent b5693f2 commit 265615e

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

core/timermanager.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ uint64_t TimerManager::process_timers()
9595
cur_timer = this->timer_queue.top();
9696
} // ] mtx scope
9797
while (cur_timer->timeout_ns <= time_now) {
98+
this->timer_queue.remove_by_id(cur_timer->id);
9899
uint64_t timeout_ns = cur_timer->timeout_ns;
99100
timer_cb cb = cur_timer->cb;
100101

@@ -105,11 +106,7 @@ uint64_t TimerManager::process_timers()
105106
if (timeout_ns_new <= time_now)
106107
timeout_ns_new = time_now + cur_timer->interval_ns;
107108
cur_timer->timeout_ns = timeout_ns_new;
108-
this->timer_queue.remove_by_id(cur_timer->id);
109109
this->timer_queue.push(cur_timer);
110-
} else {
111-
// remove one-shot timers from queue
112-
this->timer_queue.pop();
113110
}
114111

115112
this->cb_active = true;

0 commit comments

Comments
 (0)