Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loop ¶
type Loop struct {
// Startup runs on the loop's goroutine at the start of every run, before the
// first cycle. What it returns runs when the run ends.
Startup func() (cleanup func())
// SerialRuns makes a new run wait for the previous one to have left its
// cycle before it begins, which delays a restart by as long as a cycle can
// last. Off by default, a run then begins while the previous one may still
// be finishing.
SerialRuns bool
// contains filtered or unexported fields
}
Loop runs a cycle on its own goroutine until it is stopped, waiting between them either a fixed period or the duration the cycle itself returns. Start and Stop can be called in any order and as many times as needed.
Stop does not wait for the cycle under way: it asks the loop to end and returns.
func NewAdaptiveLoop ¶
func NewAdaptiveLoop(name string, owner clock.ClockInterface, first time.Duration, cycle func() time.Duration) *Loop
NewAdaptiveLoop returns a Loop whose cycle returns how long to wait before the next one. first is the wait before the very first cycle.
Click to show internal directories.
Click to hide internal directories.