queue

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 5 Imported by: 2

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 an element from the queue. Result can be nil if no more elements are present in the queue.

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