blob: 62cc03bd1530684dd822cd91a1481fdecea8187f [file] [log] [blame]
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -07001.. _module-pw_chrono:
2
3---------
4pw_chrono
5---------
6Pigweed's chrono module provides facilities for applications to deal with time,
7leveraging many pieces of STL's the ``std::chrono`` library but with a focus
8on portability for constrained embedded devices and maintaining correctness.
9
Ewout van Bekkumcc756c82021-05-12 07:57:43 -070010At a high level Pigweed's time primitives rely on C++'s
11`<chrono> <https://en.cppreference.com/w/cpp/header/chrono>`_ library to enable
12users to express intents with strongly typed real time units. In addition, it
13extends the C++ named
14`Clock <https://en.cppreference.com/w/cpp/named_req/Clock>`_ and
15`TrivialClock <https://en.cppreference.com/w/cpp/named_req/TrivialClock>`_
16requirements with additional attributes such as whether a clock is monotonic
17(not just steady), is always enabled (or requires enabling), is free running
18(works even if interrupts are masked), whether it is safe to use in a
19Non-Maskable Interrupts (NMI), what the epoch is, and more.
20
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070021.. warning::
Ewout van Bekkumcc756c82021-05-12 07:57:43 -070022 This module is still under construction, the API is not yet stable. Also the
23 documentation is incomplete.
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070024
25SystemClock facade
26------------------
27The ``pw::chrono::SystemClock`` is meant to serve as the clock used for time
28bound operations such as thread sleeping, waiting on mutexes/semaphores, etc.
29The ``SystemClock`` always uses a signed 64 bit as the underlying type for time
30points and durations. This means users do not have to worry about clock overflow
31risk as long as rational durations and time points as used, i.e. within a range
32of ±292 years.