Documentation ¶
Index ¶
- type Fake
- func (fec *Fake) EventAfterDuration(f eventclock.EventFunc, d time.Duration)
- func (fec *Fake) EventAfterTime(f eventclock.EventFunc, t time.Time)
- func (fec *Fake) GetNextTime() (time.Time, bool)
- func (fec *Fake) Run(limit *time.Time)
- func (fec *Fake) SetTime(t time.Time)
- func (fec *Fake) Sleep(duration time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct { baseclocktest.FakePassiveClock // contains filtered or unexported fields }
Fake is one whose time does not pass implicitly but rather is explicitly set by invocations of its SetTime method. Each Fake has an associated GoRoutineCounter that is used to track associated activity. For the EventAfterDuration and EventAfterTime methods, the clock itself counts the start and stop of the EventFunc and the client is responsible for counting any suspend and resume internal to the EventFunc. The Sleep method must only be invoked from a goroutine that is counted in that GoRoutineCounter.
func NewFake ¶
NewFake constructs a new fake event clock. The given `r *rand.Rand` must henceforth not be used for any other purpose. If `r` is nil then a fresh one will be constructed, seeded with the current real time. The clientWG can be `nil` and if not is used to let Run know about additional work that has to complete before time can advance.
func (*Fake) EventAfterDuration ¶
func (fec *Fake) EventAfterDuration(f eventclock.EventFunc, d time.Duration)
EventAfterDuration schedules the given function to be invoked once the given duration has passed.
func (*Fake) EventAfterTime ¶
func (fec *Fake) EventAfterTime(f eventclock.EventFunc, t time.Time)
EventAfterTime schedules the given function to be invoked once the given time has arrived.
func (*Fake) GetNextTime ¶
GetNextTime returns the next time at which there is work scheduled, and a bool indicating whether there is any such time
func (*Fake) Run ¶
Run runs all the events scheduled, and all the events they schedule, and so on, until there are none scheduled or the limit is not nil and the next time would exceed the limit. The associated GoRoutineCounter gates the advancing of time. That is, time is not advanced until all the associated work is finished.
func (*Fake) SetTime ¶
SetTime sets the time and runs to completion all events that should be started by the given time --- including any further events they schedule
func (*Fake) Sleep ¶
Sleep returns after the given duration has passed. Sleep must only be invoked in a goroutine that is counted in the Fake's associated GoRoutineCounter. Unlike the base FakeClock's Sleep, this method does not itself advance the clock but rather leaves that up to other actors (e.g., Run).