Function createLeanTimer
Creates a new timer with a lean callback mechanism.
Timer createLeanTimer(CALLABLE)
(
CALLABLE callback
)
if (is(typeof(() nothrow @safe
{
callback();
}
())) || is(typeof(() nothrow @safe
{
callback(Timer .init);
}
())));
In contrast to the standard createTimer
, callback
will not be called
in a new task, but is instead called directly in the context of the event
loop.
For this reason, the supplied callback is not allowed to perform any
operation that needs to block/yield execution. In this case, runTask
needs to be used explicitly to perform the operation asynchronously.
Additionally, callback
can carry arbitrary state without requiring a heap
allocation.