Function Reactor.registerRecurringTimer

registers a timer that will repeatedly trigger at set intervals.

Reactor.TimerHandle registerRecurringTimer (
  core.time.Duration interval,
  void delegate() dg
) nothrow @nogc @safe;

Reactor.TimerHandle registerRecurringTimer(alias F) (
  Duration interval,
  Parameters!F params
) nothrow @nogc @safe;

Reactor.TimerHandle registerRecurringTimer (
  core.time.Duration interval,
  void delegate() dg,
  Timeout firstRun
) nothrow @nogc @safe;

Reactor.TimerHandle registerRecurringTimer(alias F) (
  Duration interval,
  Parameters!F params,
  Timeout firstRun
) nothrow @nogc @safe;

You do not control precisely when the callback is invoked, only how often. The invocations are going to be evenly spaced out (best effort), but the first invocation might be almost immediately after the call or a whole interval after.

You can use the firstRun argument to control when the first invocation is going to be (but the same rule will still apply to the second one).

Parameters

NameDescription
interval the frequency with which the callback will be called.
dg the callback to invoke
F an alias to the function to be called
params the arguments to pass to F on each invocation
firstRun if supplied, directly sets when is the first time the timer shall run. The value does not have any special constraints.