template<typename Clock>
class pw::async2::SimulatedTimeProvider< Clock >
A simulated TimeProvider
suitable for testing APIs which use Timer
.
|
| SimulatedTimeProvider (typename Clock::time_point timestamp=typename Clock::time_point(typename Clock::duration(0))) |
|
void | AdvanceTime (typename Clock::duration duration) |
| Advances the simulated time and runs any newly-expired timers.
|
|
bool | AdvanceUntilNextExpiration () |
|
void | SetTime (typename Clock::time_point new_now) |
|
void | RunExpiredTimers () |
|
Clock::time_point | now () final |
| Returns the current time.
|
|
std::optional< typename Clock::time_point > | NextExpiration () |
|
std::optional< typename Clock::duration > | TimeUntilNextExpiration () |
|
Clock::time_point | now () override=0 |
| Returns the current time.
|
|
TimeFuture< Clock > | WaitFor (typename Clock::duration delay) |
|
TimeFuture< Clock > | WaitUntil (typename Clock::time_point timestamp) |
|
virtual Clock::time_point | now ()=0 |
| Returns the current time.
|
|
template<typename Clock >
Explicitly run expired timers.
Calls to this function are not usually necessary, as AdvanceTime
and SetTime
will trigger expired timers to run. However, if a timer is set for a time in the past and neither AdvanceTime
nor SetTime
are subsequently invoked, the timer will not have a chance to run until one of AdvanceTime
, SetTime
, or RunExpiredTimers
has been called.