Documentation
¶
Overview ¶
Package taskloop implements a task loop to run tasks sequentially in a separate Goroutine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("the agent is closed")
ErrClosed indicates that the loop has been stopped.
Functions ¶
This section is empty.
Types ¶
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop runs submitted task serially in a dedicated Goroutine.
func (*Loop) Close ¶
func (l *Loop) Close()
Close stops the loop after finishing the execution of the current task. Other pending tasks will not be executed.
func (*Loop) CloseWithPreStop ¶ added in v4.3.0
func (l *Loop) CloseWithPreStop(preStop func())
CloseWithPreStop stops the loop after finishing the execution of the current task. It calls preStop after the loop is marked closed and before waiting for the current task to return.
func (*Loop) Done ¶
func (l *Loop) Done() <-chan struct{}
Done returns a channel that's closed when the task loop has been stopped.
func (*Loop) Err ¶
Err returns nil if the task loop is still running. Otherwise it return errClosed if the loop has been closed/stopped.