xref: /aosp_15_r20/external/pigweed/pw_chrono_stl/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_chrono_stl:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker-------------
4*61c4878aSAndroid Build Coastguard Workerpw_chrono_stl
5*61c4878aSAndroid Build Coastguard Worker-------------
6*61c4878aSAndroid Build Coastguard Worker``pw_chrono_stl`` is a collection of ``pw_chrono`` backends that are implemented
7*61c4878aSAndroid Build Coastguard Workerusing STL's ``std::chrono`` library.
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Worker.. warning::
10*61c4878aSAndroid Build Coastguard Worker  This module is still under construction, the API is not yet stable.
11*61c4878aSAndroid Build Coastguard Worker
12*61c4878aSAndroid Build Coastguard WorkerSystemClock backend
13*61c4878aSAndroid Build Coastguard Worker-------------------
14*61c4878aSAndroid Build Coastguard WorkerThe STL based ``pw_chrono_stl:system_clock`` backend target implements the
15*61c4878aSAndroid Build Coastguard Worker``pw_chrono:system_clock`` facade by using the ``std::chrono::steady_clock``.
16*61c4878aSAndroid Build Coastguard WorkerNote that the ``std::chrono::system_clock`` cannot be used as this is not always
17*61c4878aSAndroid Build Coastguard Workera monotonic clock source.
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard WorkerSee the documentation for ``pw_chrono`` for further details.
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard WorkerSystemTimer backend
22*61c4878aSAndroid Build Coastguard Worker-------------------
23*61c4878aSAndroid Build Coastguard WorkerThe STL based ``pw_chrono_stl:system_timer`` backend target implements the
24*61c4878aSAndroid Build Coastguard Worker``pw_chrono:system_timer`` facade by spawning a detached thread for every single
25*61c4878aSAndroid Build Coastguard Worker``InvokeAt()`` and ``InvokeAfter()`` call. This thread simply sleeps until the
26*61c4878aSAndroid Build Coastguard Workerdesired ``expiration_deadline`` and invokes the user's ``ExpiryCallback`` if it
27*61c4878aSAndroid Build Coastguard Workerwasn't cancelled.
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Worker.. Warning::
30*61c4878aSAndroid Build Coastguard Worker  Although fully functional, the current implementation is NOT efficient!
31*61c4878aSAndroid Build Coastguard Worker
32*61c4878aSAndroid Build Coastguard WorkerSee the documentation for ``pw_chrono`` for further details.
33*61c4878aSAndroid Build Coastguard Worker
34*61c4878aSAndroid Build Coastguard WorkerBuild targets
35*61c4878aSAndroid Build Coastguard Worker-------------
36*61c4878aSAndroid Build Coastguard WorkerThe GN build for ``pw_chrono_stl`` has one target: ``system_clock``.
37*61c4878aSAndroid Build Coastguard WorkerThe ``system_clock`` target provides the
38*61c4878aSAndroid Build Coastguard Worker``pw_chrono_backend/system_clock_config.h`` and
39*61c4878aSAndroid Build Coastguard Worker``pw_chrono_backend/system_clock_inline.h`` headers and the backend for the
40*61c4878aSAndroid Build Coastguard Worker``pw_chrono:system_clock``.
41