queue
import "github.com/smallnest/queue"
Package queue provides multiple queue implementations.
The lock-free and two-lock algorithms are from Michael and Scott. https://doi.org/10.1145/248052.248106
Queue
A queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence.The operations of a queue make it a first-in-first-out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed.
Package queue defines Queue
interface:
type Queue[T any] interface {
Enqueue(v T)
Dequeue() T
}
Currently it contains three implementations:
- lock-free queue:
LKQueue
- two-lock queue:
CQueue
- slice-based queue:
SliceQueue
Benchmark
goos: darwin
goarch: amd64
pkg: github.com/smallnest/queue
BenchmarkQueue/lock-free_queue
BenchmarkQueue/two-lock_queue
BenchmarkQueue/slice-based_queue
BenchmarkQueue/two-lock_queue
BenchmarkQueue/slice-based_queue
BenchmarkQueue/lock-free_queue
BenchmarkQueue/lock-free_queue
BenchmarkQueue/two-lock_queue
BenchmarkQueue/slice-based_queue