Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var InactiveError = fmt.Errorf("inactive task queue")
Functions ¶
This section is empty.
Types ¶
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
A queue for running jobs serially.
func NewTaskQueue ¶
func (*TaskQueue) Enqueue ¶
Pushes the specified function onto the task queue. When the job completes, the result is sent over the returned channel
func (*TaskQueue) Start ¶
Starts the task queue. A task queue must be started before jobs can be enqueued to it.
func (*TaskQueue) Stop ¶
Stops the task queue. If there are any queued jobs, this causes them to fail with the specified error. The task queue must be started again before it can be reused. This function blocks until the task loop returns, so alling this from within a job results in deadlock. If a job needs to stop the task queue, it should use StopNoWait instead.
func (*TaskQueue) StopNoWait ¶
Stops the task queue. If there are any queued jobs, this causes them to fail with the specified error. The task queue must be started again before it can be reused. If this function returns success, the stop procedure has successfully initiated, but not necessarily completed.