Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SysSleepConsumer = func(d time.Duration) { time.Sleep(d) }
SysSleepConsumer is the default system sleep consumer
var SysTimeProvider = func() time.Time { return time.Now() }
SysTimeProvider is the default system time provider
Functions ¶
This section is empty.
Types ¶
type SleepConsumer ¶
SleepConsumer sleeps the given amount of time. This is usually the time.Sleep method, but can be something else for unit tests.
type TimeProvider ¶
A TimeProvider returns the current time. This is usually the system time, but can be something else for unit tests.
func NewFixedTimeProviderFromNanoSeconds ¶ added in v0.25.0
func NewFixedTimeProviderFromNanoSeconds(timestamp int64) TimeProvider
NewFixedTimeProviderFromNanoSeconds creates a time provider from long nano seconds that always returns a fixed time
func NewFixedTimeProviderFromSeconds ¶ added in v0.25.0
func NewFixedTimeProviderFromSeconds(timestamp float64) TimeProvider
NewFixedTimeProviderFromSeconds creates a time provider from floating point seconds that always returns a fixed time
type Timer ¶
type Timer struct { TimeProvider TimeProvider SleepConsumer SleepConsumer // contains filtered or unexported fields }
A Timer can be started and stopped. It will start at zero and count up, while running. It is event driven, there are now threads that update any state.
func (*Timer) WaitTillNextFull ¶ added in v0.6.0
WaitTillNextFull waits until the internal timer has reached the next full given duration
func (*Timer) WaitTillNextFullSecond ¶
func (t *Timer) WaitTillNextFullSecond()
WaitTillNextFullSecond waits until the internal timer has reached the next full second