Documentation
¶
Overview ¶
Package timer provides abstract interfaces to represent an event of elapsed time. It also provides implementation of those interfaces using Timer type from the standard time package. These interfaces make it easier to implement unit tests for components that operate with timeout events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
// NewTimer creates a new Timer that is to expire at least
// after duration d.
NewTimer(d time.Duration) Timer
// AfterFunc creates a new Timer that is to expire at least
// after duration d. The supplied callback function f is
// invoked in a spawned goroutine upon the timer expiration.
AfterFunc(d time.Duration, f func()) Timer
}
Provider is an interface of abstract timer implementation.
type Timer ¶
type Timer interface {
// Expired returns a channel to receive the current time when
// the timer expires.
Expired() <-chan time.Time
// Reset reschedules the timer to expire after duration d. It
// should only be used on an inactive timer.
Reset(d time.Duration)
// Stop cancels the timer. It returns true if the timer has
// been stopped by this invocation before expiration.
Stop() bool
}
Timer is an interface to manipulate with an event of elapsed time.
Click to show internal directories.
Click to hide internal directories.