queue

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 6 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue added in v1.0.0

type Queue struct {
	sync.Mutex
	Timeout  time.Duration
	Strategy Strategy
	// contains filtered or unexported fields
}

Queue is a queue that implements bucket based depth-first or breadth-first queue.

The breadth-first queues allow defining scores on whose basis the bucket is distributed. Lower scores are picked up first, and higher scores which have a greater chance of being just random noise are picked up later in depth first.

Depth-first queue uses a simple stack for LIFO operations and distributes items as they come in.

func New

func New(strategyName string, timeout int) (*Queue, error)

New creates a new queue from the type specified.

func (*Queue) Len added in v1.0.0

func (q *Queue) Len() int

Len returns the number of items in queue.

func (*Queue) Pop added in v1.0.0

func (q *Queue) Pop() chan interface{}

Pop pops elements from the queue (backward-compatible, no context).

func (*Queue) PopWithContext added in v1.7.0

func (q *Queue) PopWithContext(ctx context.Context) chan interface{}

PopWithContext pops elements from the queue, respecting context cancellation. If ctx is nil, context.Background() is used.

func (*Queue) Push added in v1.0.0

func (q *Queue) Push(x interface{}, priority int)

Push pushes an element with an optional priority into the queue.

type Strategy added in v1.0.0

type Strategy int

Strategy of the queue

const (
	BreadthFirst Strategy = iota
	DepthFirst
)

strategies of queues available for selection.

func (Strategy) String added in v1.0.0

func (s Strategy) String() string

Jump to

Keyboard shortcuts

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