kernel/time/clock
Classes
Section titled “Classes”ManualClock
Section titled “ManualClock”Defined in: app/src/kernel/time/clock.ts:36
A Clock whose time only moves when ManualClock.advance is called. Used in tests and for deterministic replays.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ManualClock(
start?,epoch?):ManualClock
Defined in: app/src/kernel/time/clock.ts:45
Parameters
Section titled “Parameters”start?
Section titled “start?”number = 0
Initial monotonic time in milliseconds.
epoch?
Section titled “epoch?”number = 0
Wall time that corresponds to monotonic time 0.
Returns
Section titled “Returns”Accessors
Section titled “Accessors”pendingTimers
Section titled “pendingTimers”Get Signature
Section titled “Get Signature”get pendingTimers():
number
Defined in: app/src/kernel/time/clock.ts:92
Number of timers that are scheduled and not cancelled.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”advance()
Section titled “advance()”advance(
ms):void
Defined in: app/src/kernel/time/clock.ts:75
Moves time forward and runs every timer that becomes due, in order of due time.
Parameters
Section titled “Parameters”number
Milliseconds to advance.
Returns
Section titled “Returns”void
now():
number
Defined in: app/src/kernel/time/clock.ts:51
Milliseconds from a monotonic clock, suitable for measuring durations.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”setTimeout()
Section titled “setTimeout()”setTimeout(
callback,delayMs):Disposable
Defined in: app/src/kernel/time/clock.ts:61
Runs a callback once after a delay.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Function to run.
delayMs
Section titled “delayMs”number
Delay in milliseconds.
Returns
Section titled “Returns”A disposable that cancels the timer.
Implementation of
Section titled “Implementation of”wallTime()
Section titled “wallTime()”wallTime():
number
Defined in: app/src/kernel/time/clock.ts:56
Milliseconds since the Unix epoch, for timestamps.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”Interfaces
Section titled “Interfaces”Defined in: app/src/kernel/time/clock.ts:8
Source of time and timers. The kernel never touches host timers directly, so tests can drive time deterministically and the kernel stays free of host APIs.
Methods
Section titled “Methods”now():
number
Defined in: app/src/kernel/time/clock.ts:10
Milliseconds from a monotonic clock, suitable for measuring durations.
Returns
Section titled “Returns”number
setTimeout()
Section titled “setTimeout()”setTimeout(
callback,delayMs):Disposable
Defined in: app/src/kernel/time/clock.ts:19
Runs a callback once after a delay.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Function to run.
delayMs
Section titled “delayMs”number
Delay in milliseconds.
Returns
Section titled “Returns”A disposable that cancels the timer.
wallTime()
Section titled “wallTime()”wallTime():
number
Defined in: app/src/kernel/time/clock.ts:12
Milliseconds since the Unix epoch, for timestamps.
Returns
Section titled “Returns”number
Variables
Section titled “Variables”ClockToken
Section titled “ClockToken”Defined in: app/src/kernel/time/clock.ts:23
Token for the Clock.