Pigweed
 
Loading...
Searching...
No Matches
pw::chrono::VirtualClock< Clock > Class Template Referenceabstract

#include <virtual_clock.h>

Inheritance diagram for pw::chrono::VirtualClock< Clock >:
pw::async2::TimeProvider< Clock > pw::async2::SimulatedTimeProvider< Clock >

Public Member Functions

virtual Clock::time_point now ()=0
 Returns the current time.
 

Detailed Description

template<typename Clock>
class pw::chrono::VirtualClock< Clock >

An abstract interface representing a Clock.

This interface allows decoupling code that uses time from the code that creates a point in time. You can use this to your advantage by injecting Clocks into interfaces rather than having implementations call SystemClock::now() directly. However, this comes at a cost of a vtable per implementation and more importantly passing and maintaining references to the VirtualClock for all of the users.

This interface is thread and IRQ safe.

Member Function Documentation

◆ now()

template<typename Clock >
virtual Clock::time_point pw::chrono::VirtualClock< Clock >::now ( )
pure virtual

Returns the current time.

Implemented in pw::async2::SimulatedTimeProvider< Clock >, and pw::async2::TimeProvider< Clock >.


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