C/C++ API Reference
Loading...
Searching...
No Matches
pw::chrono::SystemClock Struct Reference

Overview

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:

Example:

SystemClock::time_point before = SystemClock::now();
TakesALongTime();
SystemClock::duration time_taken = SystemClock::now() - before;
bool took_way_too_long = false;
if (time_taken > std::chrono::seconds(42)) {
took_way_too_long = true;
}
static time_point now() noexcept
This is thread and IRQ safe. This must be provided by the backend.
Definition: system_clock.h:117
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:90

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
 

The documentation for this struct was generated from the following file: