Skip to content

ludus::foundation::time::Stopwatch

Ludus Wiki · API overview · Browse API

Class

Owner-local value.
Supply one timestamp to all timers in an update; use synthetic samples in tests/replay. Samples must share a monotonic domain. Failed transitions/reads preserve state/output. Read is observational and validates against the last transition, not previous observational reads.

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

#include <ludus/foundation/time/timers.hpp>
class ludus::foundation::time::Stopwatch final

Methods

Reset

void ludus::foundation::time::Stopwatch::Reset() noexcept
Discard accumulated time and enter Stopped state.

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

Start

void ludus::foundation::time::Stopwatch::Start(Timestamp now) noexcept
Start a new interval at now, discarding all previous accumulated time.

Related types: Timestamp

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

Pause

TimeStatus ludus::foundation::time::Stopwatch::Pause(Timestamp now) noexcept
Accumulate through now and pause; invalid state, regression or overflow preserves state.

Returns

Ok only from Running with a valid, representable interval.

Related types: TimeStatus · Timestamp

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

Resume

TimeStatus ludus::foundation::time::Stopwatch::Resume(Timestamp now) noexcept
Resume a Paused interval, excluding paused time; other states return InvalidState. ClockRegression preserves state when now precedes the pause sample.

Related types: TimeStatus · Timestamp

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

Read

TimeStatus ludus::foundation::time::Stopwatch::Read(Timestamp now, Duration &out) const noexcept
Read accumulated elapsed time without changing state; failure preserves out. Paused ignores now; Running checks regression and overflow; Stopped returns InvalidState.

Related types: TimeStatus · Duration · Timestamp

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

GetState

StopwatchState ludus::foundation::time::Stopwatch::GetState() const noexcept
Return the current lifecycle state without sampling the clock.

Related types: StopwatchState

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