A simulated clock is a concrete Clock implementation that does not "tick" on its own. Time is advanced by explicit calls to the AdvanceTime() or SetTime() functions.
Synopsis
Declared in <absl/time/simulated_clock.h>
class SimulatedClock
: public Clock
Description
Example: absl::SimulatedClock sim_clock; absl::Time now = sim_clock.TimeNow(); // now == absl::UnixEpoch()
now = sim_clock.TimeNow(); // now == absl::UnixEpoch() (still)
sim_clock.AdvanceTime(absl::Seconds(3)); now = sim_clock.TimeNow(); // now == absl::UnixEpoch() + absl::Seconds(3)
This class is thread‐safe.
Base Classes
Name |
Description |
An abstract interface representing a Clock, which is an object that can tell you the current time, sleep, and wait for a condition variable. |
Member Functions
Name |
Description |
|
Constructors |
|
Destroys the simulated clock. |
Advances the simulated time by the specified duration. Wakes up any threads whose sleeps have now expired. Returns the number of woken threads. |
|
|
Blocks until the condition is true or until the simulated clock is advanced to or beyond the wakeup time (or both). |
Returns the earliest wakeup time. |
|
Sets the simulated time to the argument. Wakes up any threads whose sleeps have now expired. Returns the number of woken threads. |
|
|
Sleeps until the specified duration has elapsed according to this clock. |
|
Sleeps until the specified wakeup_time. |
|
Returns the simulated time. |
Static Member Functions
Name |
Description |
Returns a reference to the global realtime clock. The returned clock is thread‐safe. |
Created with MrDocs