syncqueue

package
v0.76.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package syncqueue provides queues for concurrent use.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmpty = errors.New("empty queue")

Functions

This section is empty.

Types

type SyncQueue

type SyncQueue[T any] struct {
	// contains filtered or unexported fields
}

SyncQueue represents an unlimited FIFO queue which can be used to synchronize goroutines.

func New

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

New returns a new SyncQueue.

func (*SyncQueue[T]) Get

func (q *SyncQueue[T]) Get(ctx context.Context) (T, error)

Get returns an item from the queue or waits until an item is available. The operation will be aborted when the provided context is canceled.

If there are multiple goroutines waiting it is undefined which one retrieves a new item.

func (*SyncQueue[T]) GetNoWait

func (q *SyncQueue[T]) GetNoWait() (T, error)

GetNoWait returns the item from the top of the queue or an error when the queue is empty.

func (*SyncQueue[T]) IsEmpty

func (q *SyncQueue[T]) IsEmpty() bool

IsEmpty reports whether the queue is empty.

func (*SyncQueue[T]) Put

func (q *SyncQueue[T]) Put(v T)

Put adds an item in the queue.

func (*SyncQueue[T]) Size

func (q *SyncQueue[T]) Size() int

Size returns the number of items in the queue.

Jump to

Keyboard shortcuts

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