mpscqueue

package
v0.0.0-...-13747d4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT, BSD-2-Clause-Views Imports: 1 Imported by: 1

Documentation

Overview

Package mpscqueue is a multi-producer, single-consumer queue.

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 implements a lock-free multi-producer single-consumer queue.

The design is based on http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue.

func New

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

New creates a Queue.

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() (value T, ok bool)

Dequeue receives a value from the queue, or returns ok=false if there weren't any values.

Dequeue is not safe to call concurrently.

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(value T)

Enqueue adds a value to the queue.

Enqueue is safe to call concurrently.

func (*Queue[T]) Init

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

Init initializes the queue for receiving.

Jump to

Keyboard shortcuts

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