From f5665aa7c105b3f8ece6adf047de980d2e98617c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 27 Oct 2018 16:31:59 +0200 Subject: [PATCH] Fix compilation on older DMD frontends. --- source/vibe/core/core.d | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source/vibe/core/core.d b/source/vibe/core/core.d index e40db1d..abdfa12 100644 --- a/source/vibe/core/core.d +++ b/source/vibe/core/core.d @@ -1039,7 +1039,7 @@ struct Timer { if (callback) { m_driver.timers.userData!Callback(m_id) = callback; - m_driver.timers.wait(m_id, timerCallbackHandler); + m_driver.timers.wait(m_id, &TimerCallbackHandler.instance.handle); } } @@ -1094,15 +1094,19 @@ struct Timer { } } -private immutable TimerCallback2 timerCallbackHandler = (TimerID timer, bool fired) { - if (fired) { - auto cb = eventDriver.timers.userData!(Timer.Callback)(timer); - cb(); - } +struct TimerCallbackHandler { + static TimerCallbackHandler instance; + void handle(TimerID timer, bool fired) + @safe nothrow { + if (fired) { + auto cb = eventDriver.timers.userData!(Timer.Callback)(timer); + cb(); + } - if (!eventDriver.timers.isUnique(timer)) - eventDriver.timers.wait(timer, timerCallbackHandler); -}; + if (!eventDriver.timers.isUnique(timer)) + eventDriver.timers.wait(timer, &handle); + } +} /** Returns an object that ensures that no task switches happen during its life time.