vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

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


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 a Timer object that can be used to identify and modify the timer.

See also



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.

Timer setTimer (
  core.time.Duration timeout,
  void delegate() callback,
  bool periodic = false

Sönke Ludwig


© 2012-2019 RejectedSoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.