basicmpmc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: AGPL-3.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 BasicMPMCQueue

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

BasicMPMCQueue is a bounded, lock‑free, multi‑producer/multi‑consumer queue.

func New

func New[T any](capacity uint64) *BasicMPMCQueue[T]

New creates a new BasicMPMCQueue with the given capacity (rounded up to a power of 2).

func (*BasicMPMCQueue[T]) Dequeue

func (q *BasicMPMCQueue[T]) Dequeue() (T, bool)

Dequeue removes and returns a value from the queue. It spins until a cell is ready.

func (*BasicMPMCQueue[T]) Enqueue

func (q *BasicMPMCQueue[T]) Enqueue(val T)

Enqueue inserts a value into the queue. It spins until a slot is available.

func (*BasicMPMCQueue[T]) FreeSlots

func (q *BasicMPMCQueue[T]) FreeSlots() uint64

FreeSlots returns how many slots are free.

func (*BasicMPMCQueue[T]) UsedSlots

func (q *BasicMPMCQueue[T]) UsedSlots() uint64

UsedSlots returns an approximate count of used slots.

Jump to

Keyboard shortcuts

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