eve.rt.timer

Runtime Layer Timer Primitives

This module provides high-level asynchronous timer primitives built on top of the EVE event loop. Unlike the low-level eve.core.timer which defines timer specifications, this module provides ready-to-use async timer operations for use with fibers and futures.

Types 4

enumTimerState : ubyte

State of an async timer operation.

PENDINGTimer has not been started yet.
RUNNINGTimer is currently running and waiting to fire.
COMPLETEDTimer has fired and completed.
CANCELLEDTimer was cancelled before firing.

High-level asynchronous timer for use with the runtime layer.

An AsyncTimer wraps the low-level timer machinery and provides a higher-level interface suitable for use with fibers and futures. It supports one-shot delays, repeating intervals, and cancellation.

Fields
private TimerSpec spec_
private TimerState state_
private ulong fireCount_
Methods
AsyncTimer oneShot(long delayMs) pure @safe nothrow @nogcCreates a one-shot timer that fires after the specified delay.
AsyncTimer repeating(long intervalMs, long initialDelayMs = - 1) pure @safe nothrow @nogcCreates a repeating timer with the specified interval.
TimerSpec spec() @property const pure @safe nothrow @nogcReturns the underlying timer specification.
TimerState state() @property const pure @safe nothrow @nogcReturns the current state of the timer.
ulong fireCount() @property const pure @safe nothrow @nogcReturns the number of times this timer has fired.
bool isRepeating() @property const pure @safe nothrow @nogcReports whether this timer repeats after firing.
bool isRunning() @property const pure @safe nothrow @nogcReports whether the timer is currently running.
void start() pure @safe nothrow @nogcStarts the timer.
void cancel() pure @safe nothrow @nogcCancels a running timer.
void reset() pure @safe nothrow @nogcResets the timer to its initial pending state.
void recordFire() pure @safe nothrow @nogcRecords a timer firing event.
Constructors
this(long delayMs, long intervalMs = 0)Constructs an async timer with the specified delay and interval.
structTimeout

Configuration for timeout operations.

A Timeout wraps a duration and can be used to limit the time spent waiting for an operation to complete.

Fields
long durationMsThe timeout duration in milliseconds.
bool expiredIndicates whether the timeout has been exceeded.
Methods
Timeout fromMs(long ms) pure @safe nothrow @nogcCreates a timeout from milliseconds.
Timeout fromSecs(long secs) pure @safe nothrow @nogcCreates a timeout from seconds.
bool isImmediate() @property const pure @safe nothrow @nogcReports whether the timeout duration is zero or negative.
bool isSet() @property const pure @safe nothrow @nogcReports whether a timeout has been configured.
Constructors
this(long ms)Constructs a timeout with the specified duration.
structSleep

Represents a sleep duration for suspending execution.

A Sleep is a high-level primitive for pausing fiber execution for a specified duration. Unlike AsyncTimer, a sleep is always a one-shot operation.

Fields
private long durationMs_
private bool completed_
Methods
Sleep ms(long ms) pure @safe nothrow @nogcCreates a sleep from milliseconds.
Sleep secs(long secs) pure @safe nothrow @nogcCreates a sleep from seconds.
long durationMs() @property const pure @safe nothrow @nogcReturns the sleep duration in milliseconds.
bool completed() @property const pure @safe nothrow @nogcReports whether the sleep has completed.
void markCompleted() pure @safe nothrow @nogcMarks the sleep as completed.
Constructors
this(long ms)Constructs a sleep with the specified duration.