[#absl-SimulatedClock]
= xref:absl.adoc[absl]::SimulatedClock
:relfileprefix: ../
:mrdocs:

A simulated clock is a concrete Clock implementation that does not &quot;tick&quot; on its own&period; Time is advanced by explicit calls to the AdvanceTime() or SetTime() functions&period;

== Synopsis

Declared in `&lt;absl&sol;time&sol;simulated&lowbar;clock&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class SimulatedClock
    : public xref:absl/Clock.adoc[Clock]
----

== Description

Example&colon; absl&colon;&colon;SimulatedClock sim&lowbar;clock&semi; absl&colon;&colon;Time now &equals; sim&lowbar;clock&period;TimeNow()&semi; &sol;&sol; now &equals;&equals; absl&colon;&colon;UnixEpoch()

now &equals; sim&lowbar;clock&period;TimeNow()&semi; &sol;&sol; now &equals;&equals; absl&colon;&colon;UnixEpoch() (still)

sim&lowbar;clock&period;AdvanceTime(absl&colon;&colon;Seconds(3))&semi; now &equals; sim&lowbar;clock&period;TimeNow()&semi; &sol;&sol; now &equals;&equals; absl&colon;&colon;UnixEpoch() &plus; absl&colon;&colon;Seconds(3)

This class is thread&hyphen;safe&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:absl/Clock.adoc[Clock]`
| An abstract interface representing a Clock, which is an object that can tell you the current time, sleep, and wait for a condition variable&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/SimulatedClock/2constructor-08.adoc[`SimulatedClock`]         [.small]#[constructor]#
| Constructors
| xref:absl/SimulatedClock/2destructor.adoc[`&#126;SimulatedClock`] [.small]#[destructor]# [.small]#[virtual]#
| Destroys the simulated clock&period;
| xref:absl/SimulatedClock/AdvanceTime.adoc[`AdvanceTime`] 
| Advances the simulated time by the specified duration&period; Wakes up any threads whose sleeps have now expired&period; Returns the number of woken threads&period;
| xref:absl/SimulatedClock/AwaitWithDeadline.adoc[`AwaitWithDeadline`]  [.small]#[virtual]#
| Blocks until the condition is true or until the simulated clock is advanced to or beyond the wakeup time (or both)&period;
| xref:absl/SimulatedClock/GetEarliestWakeupTime.adoc[`GetEarliestWakeupTime`] 
| Returns the earliest wakeup time&period;
| xref:absl/SimulatedClock/SetTime.adoc[`SetTime`] 
| Sets the simulated time to the argument&period; Wakes up any threads whose sleeps have now expired&period; Returns the number of woken threads&period;
| xref:absl/SimulatedClock/Sleep.adoc[`Sleep`]  [.small]#[virtual]#
| Sleeps until the specified duration has elapsed according to this clock&period;
| xref:absl/SimulatedClock/SleepUntil.adoc[`SleepUntil`]  [.small]#[virtual]#
| Sleeps until the specified wakeup&lowbar;time&period;
| xref:absl/SimulatedClock/TimeNow.adoc[`TimeNow`]  [.small]#[virtual]#
| Returns the simulated time&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Clock/GetRealClock.adoc[`GetRealClock`] 
| Returns a reference to the global realtime clock&period; The returned clock is thread&hyphen;safe&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
