queue

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MPSC

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

A MPSC is a bounded multi-producer single-consumer concurrent queue.

MPSC instances must be created with NewMPSC function. A MPSC must not be copied after first use.

Based on the data structure from the following C++ library: https://github.com/rigtorp/MPMCQueue

func NewMPSC

func NewMPSC[T any](capacity int) *MPSC[T]

NewMPSC creates a new MPSC instance with the given capacity.

func (*MPSC[T]) Capacity

func (q *MPSC[T]) Capacity() int

Capacity returns capacity of the queue.

func (*MPSC[T]) Clear

func (q *MPSC[T]) Clear()

Clear clears the queue.

func (*MPSC[T]) Insert

func (q *MPSC[T]) Insert(item T)

Insert inserts the given item into the queue. Blocks, if the queue is full.

func (*MPSC[T]) Remove

func (q *MPSC[T]) Remove() T

Remove retrieves and removes the item from the head of the queue. Blocks, if the queue is empty.

Jump to

Keyboard shortcuts

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