lfg

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 2 Imported by: 0

README

Go report

Lock-free Generic Queue

This is a lock-free generic queue that can be enqueued and dequeued by multiple threads.

Documentation

Overview

Package lfg implements a lock-free, multiple-producer, multiple-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[T any] is a lock-free, multiple-producer, multiple-consumer queue.

func NewQueue

func NewQueue[T any](size uint) *Queue[T]

NewQueue creates a new Queue[T any] with the given size. The size must be a power of two.

func (*Queue[T]) Dequeue

func (b *Queue[T]) Dequeue() (T, bool)

Dequeue removes an item from the queue. It returns false if the buffer is empty.

func (*Queue[T]) Enqueue

func (b *Queue[T]) Enqueue(v T) bool

Enqueue adds an item to the queue. It returns false if the buffer is full.

Jump to

Keyboard shortcuts

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