queue

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MpscQueue added in v2.5.1

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

MpscQueue is a Multi-Producer-Single-Consumer Queue reference: https://concurrencyfreaks.blogspot.com/2014/04/multi-producer-single-consumer-queue.html

func NewMpscQueue added in v2.5.1

func NewMpscQueue[T any]() *MpscQueue[T]

NewMpscQueue create an instance of MpscQueue

func (*MpscQueue[T]) IsEmpty added in v2.5.1

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

IsEmpty returns true when the queue is empty must be called from a single, consumer goroutine

func (*MpscQueue[T]) Len added in v2.5.1

func (q *MpscQueue[T]) Len() int64

Len returns queue length

func (*MpscQueue[T]) Pop added in v2.5.1

func (q *MpscQueue[T]) Pop() (T, bool)

Pop takes the QueueItem from the queue tail. Returns false if the queue is empty. Can be used in a single consumer (goroutine) only.

func (*MpscQueue[T]) Push added in v2.5.1

func (q *MpscQueue[T]) Push(value T) bool

Push place the given value in the queue head (FIFO). Returns always true

type Queue added in v2.5.0

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

Queue thread-safe Queue using ring-buffer

func New added in v2.5.0

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

New creates an instance of Unbounded

func (*Queue[T]) Cap added in v2.5.0

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

Cap return the capacity (without allocations)

func (*Queue[T]) Close added in v2.5.0

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

Close the queue and discard all entries in the queue all goroutines in wait() will return

func (*Queue[T]) CloseRemaining added in v2.5.0

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

CloseRemaining will close the queue and return all entries in the queue. All goroutines in wait() will return.

func (*Queue[T]) IsClosed added in v2.5.0

func (q *Queue[T]) IsClosed() bool

IsClosed returns true if the queue has been closed The call cannot guarantee that the queue hasn't been closed while the function returns, so only "true" has a definite meaning.

func (*Queue[T]) IsEmpty added in v2.5.0

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

IsEmpty returns true when the queue is empty

func (*Queue[T]) Len added in v2.5.0

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

Len return the current length of the queue.

func (*Queue[T]) Pop added in v2.5.0

func (q *Queue[T]) Pop() (T, bool)

Pop removes the QueueItem from the front of the queue If false is returned, it either means 1) there were no items on the queue or 2) the queue is closed.

func (*Queue[T]) Push added in v2.5.0

func (q *Queue[T]) Push(i T) bool

Push adds an QueueItem to the back of the queue It can be safely called from multiple goroutines It will return false if the queue is closed. In that case the node is dropped.

func (*Queue[T]) Wait added in v2.5.0

func (q *Queue[T]) Wait() (T, bool)

Wait for an QueueItem to be added. If there is items on the queue the first will be returned immediately. Will return nil, false if the queue is closed. Otherwise, the return value of "remove" is returned.

Jump to

Keyboard shortcuts

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