Simplify updating queue entries

The erase/insert pattern can be replaced by a single method that
updates an existing entry's timer, or inserting if it doesn't exist.

This has much less impact than the libtorrent change it's based on,
but might as well be consistent.
This commit is contained in:
kannibalox
2024-10-17 16:16:17 -04:00
committed by Jari Sundell
parent 38b39bdafc
commit 6e976616a0
6 changed files with 32 additions and 19 deletions
+2 -4
View File
@@ -64,8 +64,7 @@ Manager::force_redraw() {
void
Manager::schedule(Window* w, rak::timer t) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
rak::priority_queue_insert(&m_scheduler, w->task_update(), t);
rak::priority_queue_update(&m_scheduler, w->task_update(), t);
schedule_update(50000);
}
@@ -114,8 +113,7 @@ Manager::schedule_update(uint32_t minInterval) {
}
if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
rak::priority_queue_insert(&taskScheduler, &m_taskUpdate, std::max(m_scheduler.top()->time(), m_timeLastUpdate + minInterval));
rak::priority_queue_update(&taskScheduler, &m_taskUpdate, std::max(m_scheduler.top()->time(), m_timeLastUpdate + minInterval));
}
}