diff --git a/source/eventcore/drivers/posix.d b/source/eventcore/drivers/posix.d index 04a4e66..d74bc3f 100644 --- a/source/eventcore/drivers/posix.d +++ b/source/eventcore/drivers/posix.d @@ -84,7 +84,7 @@ abstract class PosixEventDriver : EventDriver { got_events = doProcessEvents(nextto); long prev_step = now; now = currStdTime; - processTimers(now); + got_events |= processTimers(now); if (timeout != Duration.max) timeout -= (now - prev_step).hnsecs; } while (timeout > 0.seconds && !m_exit && !got_events); diff --git a/source/eventcore/drivers/timer.d b/source/eventcore/drivers/timer.d index 9c4239d..28749b5 100644 --- a/source/eventcore/drivers/timer.d +++ b/source/eventcore/drivers/timer.d @@ -34,10 +34,10 @@ mixin template DefaultTimerImpl() { return m_timerQueue.length ? (m_timerQueue.front.timeout - stdtime).hnsecs : Duration.max; } - final protected void processTimers(long stdtime) - @trusted { + final protected bool processTimers(long stdtime) + @trusted nothrow { assert(m_firedTimers.length == 0); - if (m_timerQueue.empty) return; + if (m_timerQueue.empty) return false; TimerSlot ts = void; ts.timeout = stdtime+1; @@ -62,8 +62,12 @@ mixin template DefaultTimerImpl() { foreach (cb; tm.callbacks) cb(tm.id); + bool any_fired = m_firedTimers.length > 0; + m_firedTimers.length = 0; m_firedTimers.assumeSafeAppend(); + + return any_fired; } final override TimerID createTimer()