From 60407b783b8c64928b6cce2d4cc075467ca621d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 26 Sep 2017 15:42:03 +0200 Subject: [PATCH] Fix re-enqueuing of periodic timers. Fixes #25. Periodic timers were first re-enqueued and then removed, effectively causing them to stay at their old position, cutting off the tail of the timer queue. --- source/eventcore/drivers/timer.d | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/eventcore/drivers/timer.d b/source/eventcore/drivers/timer.d index a9bbfba..15277ea 100644 --- a/source/eventcore/drivers/timer.d +++ b/source/eventcore/drivers/timer.d @@ -51,14 +51,15 @@ final class LoopTimeoutTimerDriver : EventDriverTimers { if (tm.repeatDuration > 0) { do tm.timeout += tm.repeatDuration; while (tm.timeout <= stdtime); - enqueueTimer(tm); } else tm.pending = false; m_firedTimers ~= tm; } - // NOTE: this isn't yet verified to work under all circumstances - foreach (tm; m_firedTimers) + foreach (tm; m_firedTimers) { m_timerQueue.remove(tm); + if (tm.repeatDuration > 0) + enqueueTimer(tm); + } foreach (tm; m_firedTimers) { auto cb = tm.callback;