clock

package
v0.22.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventClock

type EventClock interface {
	clock.PassiveClock
	EventAfterDuration(f EventFunc, d time.Duration)
	EventAfterTime(f EventFunc, t time.Time)
}

EventClock fires event on time

type EventFunc

type EventFunc func(time.Time)

EventFunc does some work that needs to be done at or after the given time. After this function returns, associated work may continue

on other goroutines only if they are counted by the GoRoutineCounter

of the FakeEventClock handling this EventFunc.

type FakeEventClock

type FakeEventClock struct {
	clock.FakePassiveClock
	// contains filtered or unexported fields
}

FakeEventClock is one whose time does not pass implicitly but rather is explicitly set by invocations of its SetTime method

func NewFakeEventClock

func NewFakeEventClock(t time.Time, fuzz time.Duration, r *rand.Rand) (*FakeEventClock, counter.GoRoutineCounter)

NewFakeEventClock constructor. 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 (*FakeEventClock) EventAfterDuration

func (fec *FakeEventClock) EventAfterDuration(f EventFunc, d time.Duration)

EventAfterDuration schedules the given function to be invoked once the given duration has passed.

func (*FakeEventClock) EventAfterTime

func (fec *FakeEventClock) EventAfterTime(f EventFunc, t time.Time)

EventAfterTime schedules the given function to be invoked once the given time has arrived.

func (*FakeEventClock) GetNextTime

func (fec *FakeEventClock) GetNextTime() (time.Time, bool)

GetNextTime returns the next time at which there is work scheduled, and a bool indicating whether there is any such time

func (*FakeEventClock) Run

func (fec *FakeEventClock) Run(limit *time.Time)

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 clientWG given in the constructor gates each advance of time.

func (*FakeEventClock) SetTime

func (fec *FakeEventClock) SetTime(t time.Time)

SetTime sets the time and runs to completion all events that should be started by the given time --- including any further events they schedule

type RealEventClock

type RealEventClock struct {
	clock.RealClock
}

RealEventClock fires event on real world time

func (RealEventClock) EventAfterDuration

func (RealEventClock) EventAfterDuration(f EventFunc, d time.Duration)

EventAfterDuration schedules an EventFunc

func (RealEventClock) EventAfterTime

func (r RealEventClock) EventAfterTime(f EventFunc, t time.Time)

EventAfterTime schedules an EventFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL