From 2ff37202c04a8f49801925cc7573248f4ce64482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 29 Jan 2017 16:46:21 +0100 Subject: [PATCH] Add compatibility overload for setTimer(). --- source/vibe/core/core.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/vibe/core/core.d b/source/vibe/core/core.d index a03cd0d..4b85687 100644 --- a/source/vibe/core/core.d +++ b/source/vibe/core/core.d @@ -862,6 +862,19 @@ unittest { } } +/// Compatibility overload - use a `@safe nothrow` callback instead. +deprecated("Use anothrow callback as argument to setTimer.") +Timer setTimer(Duration timeout, void delegate() callback, bool periodic = false) +@safe nothrow { + return setTimer(timeout, () @trusted nothrow { + try callback(); + catch (Exception e) { + logWarn("Timer callback failed: %s", e.msg); + scope (failure) assert(false); + logDebug("Full error: %s", e.toString().sanitize); + } + }); +} /** Creates a new timer without arming it.