Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MultiHeadQueue ¶
type MultiHeadQueue[T any] struct { // contains filtered or unexported fields }
MultiHeadQueue is a sharded MPMC queue.
func New ¶
func New[T any](totalCapacity, numShards uint64) *MultiHeadQueue[T]
New creates a new MultiHeadQueue with the given total capacity and shard count. If numShards is zero, it defaults to runtime.NumCPU().
func (*MultiHeadQueue[T]) Dequeue ¶
func (q *MultiHeadQueue[T]) Dequeue() (T, bool)
Dequeue scans shards in round-robin order starting from a rotating index.
func (*MultiHeadQueue[T]) Enqueue ¶
func (q *MultiHeadQueue[T]) Enqueue(val T)
Enqueue inserts a value by selecting a shard in round-robin fashion.
func (*MultiHeadQueue[T]) FreeSlots ¶
func (q *MultiHeadQueue[T]) FreeSlots() uint64
FreeSlots returns the total free slots across all shards.
func (*MultiHeadQueue[T]) UsedSlots ¶
func (q *MultiHeadQueue[T]) UsedSlots() uint64
UsedSlots returns the total occupied slots across all shards.
Click to show internal directories.
Click to hide internal directories.