queue

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package queue provides a generic queue implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
	After(d time.Duration) <-chan time.Time
	Sleep(d time.Duration)
}

Clock is an interface that returns the current time and duration since a given time.

type DelayingQueue

type DelayingQueue[T comparable] interface {
	Queue[T]
	// contains filtered or unexported methods
}

DelayingQueue is a generic queue interface that supports adding items after

func NewDelayingQueue

func NewDelayingQueue[T comparable](clock Clock) DelayingQueue[T]

NewDelayingQueue returns a new DelayingQueue.

type Queue

type Queue[T any] interface {
	// Add adds an item to the queue.
	Add(item T)
	// Get returns an item from the queue.
	Get() (T, bool)
	// GetOrWait returns an item from the queue or waits until an item is added.
	GetOrWait() T
	// GetOrWaitWithDone returns an item from the queue or waits until an item is added or the done channel is closed.
	GetOrWaitWithDone(done <-chan struct{}) (T, bool)
	// Len returns the number of items in the queue.
	Len() int
}

Queue is a generic queue interface.

func NewQueue

func NewQueue[T any]() Queue[T]

NewQueue returns a new Queue.

type WeightDelayingQueue added in v0.5.0

type WeightDelayingQueue[T comparable] interface {
	Queue[T]
	// contains filtered or unexported methods
}

WeightDelayingQueue is a generic weight delaying queue interface.

func NewWeightDelayingQueue added in v0.5.0

func NewWeightDelayingQueue[T comparable](clock Clock) WeightDelayingQueue[T]

NewWeightDelayingQueue returns a new WeightDelayingQueue.

type WeightQueue added in v0.5.0

type WeightQueue[T any] interface {
	Queue[T]
	// contains filtered or unexported methods
}

WeightQueue is a generic weight queue interface.

func NewWeightQueue added in v0.5.0

func NewWeightQueue[T any]() WeightQueue[T]

NewWeightQueue returns a new WeightQueue.

Jump to

Keyboard shortcuts

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