queue

package
v0.38.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 2 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[T any] struct {
	// contains filtered or unexported fields
}

Queue is a thread-safe queue.

func New

func New[T any]() *Queue[T]

New creates a new queue.

func (*Queue[T]) Get

func (q *Queue[T]) Get() T

Get removes and returns an element from the queue. If the queue is empty, then Get will block until an element is available.

func (*Queue[T]) GetWithContext

func (q *Queue[T]) GetWithContext(ctx context.Context) (T, error)

GetWithContext removes and returns an element from the queue. If the queue is empty, then Get will block until an element is available or the context is canceled. This routine is relatively expensive---don't use it for a high throughput queue. Instead, you should probably just use a channel.

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns the number of elements in the queue.

func (*Queue[T]) Put

func (q *Queue[T]) Put(t T)

Put adds an element to the queue.

Jump to

Keyboard shortcuts

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