Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle is a delay timer with a [Sleep] method for pausing loops. It is controlled by [SlowDown] and [Reset]. It is safe for use across multiple goroutines. It is lock-free. It has a linear back-off algorithm implemented by [SlowDown] and [Speedup].
All methods in a nil *Throttle are no-op.
func New ¶
New returns a new Throttle with the minimum, initial and extra values specified.
- If minimum is less than zero it is set to zero.
- If initialStep is less than or equal to minimum, it will be set to minimum+1.
- If extraStep is less than zero, with will be set to zero.
func (*Throttle) Reset ¶
func (t *Throttle) Reset()
Reset reverts the loop delay to its minimum value.
func (*Throttle) Sleep ¶
func (t *Throttle) Sleep()
Sleep pauses this goroutine for the current loop delay. If the delay is zero, Sleep behaves as a no-op.
Click to show internal directories.
Click to hide internal directories.