The SystemClock
represents an unsteady, monotonic clock.
The epoch of this clock is unspecified and may not be related to wall time (for example, it can be time since boot). The time between ticks of this clock may vary due to sleep modes and potential interrupt handling. SystemClock
meets the requirements of C++'s TrivialClock
and Pigweed's PigweedClock.
SystemClock
is compatible with C++'s Clock
& TrivialClock
including:
SystemClock::rep
SystemClock::period
SystemClock::duration
SystemClock::time_point
SystemClock::is_steady
SystemClock::now()
Example:
This code is thread & IRQ safe, it may be NMI safe depending on is_nmi_safe.
Public Types | |
using | rep = int64_t |
using | period = std::ratio< PW_CHRONO_SYSTEM_CLOCK_PERIOD_SECONDS_NUMERATOR, PW_CHRONO_SYSTEM_CLOCK_PERIOD_SECONDS_DENOMINATOR > |
The period must be provided by the backend. | |
using | duration = std::chrono::duration< rep, period > |
Alias for durations representable with this clock. | |
using | time_point = std::chrono::time_point< SystemClock > |
Static Public Member Functions | |
static time_point | now () noexcept |
This is thread and IRQ safe. This must be provided by the backend. | |
template<class Rep , class Period > | |
static constexpr duration | for_at_least (std::chrono::duration< Rep, Period > d) |
static time_point | TimePointAfterAtLeast (duration after_at_least) |
Static Public Attributes | |
static constexpr Epoch | epoch = backend::kSystemClockEpoch |
The epoch must be provided by the backend. | |
static constexpr bool | is_monotonic = true |
static constexpr bool | is_steady = false |
static constexpr bool | is_free_running = backend::kSystemClockFreeRunning |
static constexpr bool | is_stopped_in_halting_debug_mode = true |
The clock must stop while in halting debug mode. | |
static constexpr bool | is_always_enabled = true |
The now() function can be invoked at any time. | |
static constexpr bool | is_nmi_safe = backend::kSystemClockNmiSafe |