Documentation ¶
Index ¶
- func Advance(t *testing.T, d time.Duration)
- func After(d time.Duration) <-chan time.Time
- func InitSandboxBench(_ *testing.B, start time.Time)
- func InitSandboxTest(_ *testing.T, start time.Time)
- func Now() time.Time
- func RealSleep(t *testing.T, d time.Duration)
- func Since(t time.Time) time.Duration
- func Sleep(d time.Duration)
- func Tick(d time.Duration) <-chan time.Time
- type Ticker
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Advance ¶
Advance the sandbox time by the duration d. It will panic if it is not called in sandbox mode.
func After ¶
After waits for the duration to elapse and then sends the current time on the returned channel, and is a replacement of time.After. It is equivalent to NewTimer(d).C.
func InitSandboxBench ¶
InitSandboxBench initializes the sandbox mode in benchmarks with a given start time.
func InitSandboxTest ¶
InitSandboxTest initializes the sandbox mode in tests with a given start time.
func Now ¶
Now returns the current local time, and is a replacement for time.Now. Sandbox time when in sandbox mode; system time otherwise.
func RealSleep ¶
RealSleep always pauses the current goroutine for duration d at system level. It will panic if it is not called in sandbox mode.
func Since ¶
Since returns the time elapsed since t, and is a replacement for time.Since. It is shorthand for hourglass.Now().Sub(t).
Types ¶
type Ticker ¶
type Ticker struct { C <-chan time.Time // The channel on which the ticks are delivered // contains filtered or unexported fields }
Ticker holds a channel that delivers ticks of a clock at intervals, and is a replacement of time.Ticker.
func NewTicker ¶
NewTicker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument, and is a replacement of time.NewTicker. It adjusts the intervals or drops ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic.
type Timer ¶
Timer represents a system time.Timer, or a sandboxTimer. When the Timer expires, the current time will be sent on C, unless the Timer was created by AfterFunc.
func AfterFunc ¶
AfterFunc waits for the duration to elapse and then calls f in its own goroutine, and is a replacement of time.AfterFunc. It returns a Timer that can be used to cancel the call using its Stop method.
func NewTimer ¶
NewTimer creats a new Timer that will send the current time on its channel after at least duration d, and is a replacement of time.NewTimer.
func (*Timer) Reset ¶
Reset changes the timer to expire after duration d, which is a replacement of time.Timer.Reset. It returns true if the timer had been active, false if the timer had expired or been fired.