Skip to content

ludus::foundation::time

Ludus Wiki · API overview · Browse API

Namespace

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

Enumerations

TimeStatus

enum class TimeStatus : uint8
Result of checked time arithmetic or a timer transition.

Related types: uint8

Ok

Ok
The operation succeeded and its output is available.

Overflow

Overflow
The interval or timestamp sum exceeds the uint64 range.

ClockRegression

ClockRegression
The later sample precedes the relevant earlier sample.

InvalidState

InvalidState
The requested operation is unavailable in the timer's current state.

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

StopwatchState

enum class StopwatchState : uint8
Lifecycle state of an owner-local elapsed-time accumulator.

Related types: uint8

Stopped

Stopped
No interval has been started; Read returns InvalidState.

Running

Running
Read includes time since the most recent Start or Resume.

Paused

Paused
Read returns accumulated time without including the paused interval.

Declared in modules/foundation/time/include/ludus/foundation/time/timers.hpp

Constants and variables

NANOSECONDS_PER_SECOND

constexpr uint64 ludus::foundation::time::NANOSECONDS_PER_SECOND = 1'000'000'000
Exact conversion factor from seconds to stored nanoseconds.

Related types: uint64

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

Functions

NowTicks

uint64 ludus::foundation::time::NowTicks() noexcept
Read the monotonic clock shared with profiling and logging, in nanoseconds.
No engine allocation, lock or initialization is required. Readings are non-decreasing on one thread; equal readings are valid. Units do not guarantee resolution. Timestamps do not establish a happens-before relation between threads.

Related types: uint64

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

Now

Timestamp ludus::foundation::time::Now() noexcept
Read NowTicks() as a typed timestamp in the same monotonic clock domain.

Related types: Timestamp

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

TryAdd

TimeStatus ludus::foundation::time::TryAdd(Duration left, Duration right, Duration &out) noexcept
Add interval lengths without wrapping; Overflow leaves out unchanged.

Related types: TimeStatus · Duration

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

TryAdd

TimeStatus ludus::foundation::time::TryAdd(Timestamp start, Duration interval, Timestamp &out) noexcept
Add an interval to a timestamp; Overflow leaves out unchanged.

Related types: TimeStatus · Duration · Timestamp

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

TryElapsed

TimeStatus ludus::foundation::time::TryElapsed(Timestamp start, Timestamp end, Duration &out) noexcept
Compute end minus start; ClockRegression leaves out unchanged.

Precondition

Both samples share the same monotonic clock domain.

Related types: TimeStatus · Duration · Timestamp

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp

ToSeconds

constexpr float64 ludus::foundation::time::ToSeconds(Duration interval) noexcept
Convert an interval to seconds with float64 rounding; large intervals may lose precision.

Related types: float64 · Duration

Declared in modules/foundation/time/include/ludus/foundation/time/time.hpp