queue

package
v0.0.0-...-d69ec9c Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

func (q *Queue) Len() int

Len returns the number of items in queue.

func (*Queue) Pop

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

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

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

type Strategy

type Strategy int

Strategy of the queue

const (
	BreadthFirst Strategy = iota
	DepthFirst
)

strategies of queues available for selection.

func (Strategy) String

func (s Strategy) String() string

Jump to

Keyboard shortcuts

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