BDE 4.14.0 Production release
|
#include <bdlmt_timereventscheduler.h>
Public Member Functions | |
TimerEventSchedulerTestTimeSource (TimerEventScheduler *scheduler) | |
bsls::TimeInterval | advanceTime (bsls::TimeInterval amount) |
bsls::TimeInterval | now () const |
This class provides a means to change the clock that is used by a given event-scheduler to determine when events should be triggered. Constructing a TimerEventSchedulerTestTimeSource
alters the behavior of the supplied event-scheduler. After a test time-source is created, the underlying scheduler will run events according to a discrete timeline, whose successive values are determined by calls to advanceTime
on the test time-source, and can be retrieved by calling now
on that test time-source. Note that the "system-time" held by a test time-source does not correspond to the current system time. Test writers must use caution when scheduling absolute-time events so that they are scheduled relative to the test time-source's value for now
.
|
explicit |
Construct a test time-source object that will control the "system-time" observed by the specified scheduler
. Initialize now
to be an arbitrary time value. The behavior is undefined if any methods have previously been called on scheduler
.
bsls::TimeInterval bdlmt::TimerEventSchedulerTestTimeSource::advanceTime | ( | bsls::TimeInterval | amount | ) |
Advance this object's current-time value by the specified amount
of time, and notify the scheduler that the time has changed. Return the updated current-time value. The behavior is undefined unless amount
represents a positive time interval, and now + amount
is within the range that can be represented with a bsls::TimeInterval
.
bsls::TimeInterval bdlmt::TimerEventSchedulerTestTimeSource::now | ( | ) | const |
Return this object's current-time value. Upon construction, this method will return an arbitrary value. Subsequent calls to advanceTime
will adjust the arbitrary value forward.