collections

package
v1.105.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingQueue

type BlockingQueue[T any] interface {
	// Enqueue pushes an item onto the queue
	Enqueue(item T)

	// Dequeue removes the first item from the queue and returns it.
	Dequeue() T

	// TryDequeue attempts to remove the first item from the queue and return it. This
	// method does not block, and instead, returns true if the item was available and false
	// otherwise
	TryDequeue() (T, bool)

	// Each blocks modification and allows iteration of the queue.
	Each(f func(int, T))

	// Length returns the length of the queue
	Length() int

	// IsEmpty returns true if the queue is empty
	IsEmpty() bool

	// Clear empties the queue
	Clear()
}

BlockingQueue is a queue backed by a slice which blocks if dequeueing while empty. This data structure should use a pool of worker goroutines to await work.

func NewBlockingQueue

func NewBlockingQueue[T any]() BlockingQueue[T]

NewBlockingQueue returns a new BlockingQueue implementation

Jump to

Keyboard shortcuts

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