Add compatibility overload for setTimer().

This commit is contained in:
Sönke Ludwig 2017-01-29 16:46:21 +01:00
parent 798f0ef446
commit 2ff37202c0
No known key found for this signature in database
GPG key ID: D95E8DB493EE314C

View file

@ -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.