queue

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockFreeQueue

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

LockFreeQueue implements lock-free FIFO freelist based queue. ref: https://dl.acm.org/citation.cfm?doid=248052.248106

Example
q := NewLockFreeQueue[string]()

q.Enqueue("1st item")
q.Enqueue("2nd item")
q.Enqueue("3rd item")

fmt.Println(q.Dequeue())
fmt.Println(q.Dequeue())
fmt.Println(q.Dequeue())
Output:

1st item true
2nd item true
3rd item true

func NewLockFreeQueue

func NewLockFreeQueue[T any]() *LockFreeQueue[T]

NewLockFreeQueue creates a new lock-free queue.

func (*LockFreeQueue[T]) Dequeue

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

Dequeue removes and returns the value at the head of the queue. It returns nil if the queue is empty.

func (*LockFreeQueue[T]) Enqueue

func (q *LockFreeQueue[T]) Enqueue(v T)

Enqueue puts the given value v at the tail of the queue.

func (*LockFreeQueue[T]) Len

func (q *LockFreeQueue[T]) Len() uint64

Len returns the length of the queue.

type MutexQueue

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

func NewMutexQueue

func NewMutexQueue[T any]() *MutexQueue[T]

func (*MutexQueue[T]) Dequeue

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

func (*MutexQueue[T]) Enqueue

func (q *MutexQueue[T]) Enqueue(v T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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