queue

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: BSD-3-Clause Imports: 1 Imported by: 2

README

Queue

A thread safe work queue for Go.

Based originally on the implementation found internally in the Go compiler.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue manages a set of work items to be executed in parallel. The number of active work items is limited, and excess items are queued sequentially.

func NewQueue

func NewQueue(maxActive int) *Queue

NewQueue returns a Queue that executes up to maxActive items in parallel.

maxActive must be positive.

func (*Queue) Add

func (q *Queue) Add(f func() error)

Add adds f as a work item in the queue.

Add returns immediately, but the queue will be marked as non-idle until after f (and any subsequently-added work) has completed.

func (*Queue) Wait added in v0.3.0

func (q *Queue) Wait() error

Wait blocks until the queue becomes idle. The queue is considered idle if no work items are running and no work items are waiting to run. Returns the first error encountered by a worker, or nil if all work completed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL