setTimer - multiple declarations
Function setTimer
Returns a new armed timer.
Timer setTimer
(
core .time .Duration timeout,
nothrow @safe void delegate() callback,
bool periodic = false
) nothrow @safe;
Note that timers can only work if an event loop is running, explicitly or
implicitly by running a blocking operation, such as sleep
or File
.
Parameters
Name | Description |
---|---|
timeout | Determines the minimum amount of time that elapses before the timer fires. |
callback | If non-null , this delegate will be called when the timer fires |
periodic | Speficies if the timer fires repeatedly or only once |
Returns
Returns a Timer object that can be used to identify and modify the timer.
See also
Example
void printTime()
@safe nothrow {
import std .datetime;
logInfo("The time is: %s", Clock .currTime());
}
void test()
{
import vibe .core .core;
// start a periodic timer that prints the time every second
setTimer(1 .seconds, toDelegate(&printTime), true);
}
Function setTimer
Compatibility overload - use a @safe nothrow
callback instead.