Documentation ¶
Overview ¶
Package ring provides a concurrent-safe circular queue, supports multiple read/write.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrQueueFull happens when the queue is full. ErrQueueFull = errors.New("queue is full") )
Functions ¶
This section is empty.
Types ¶
type Ring ¶
type Ring[T any] struct { // contains filtered or unexported fields }
Ring a concurrent-safe circular queue, based on the idea of Disruptor(simplified). https://lmax-exchange.github.io/disruptor/disruptor.html
func (*Ring[T]) Get ¶
Get gets an element from the circular queue, return element value and the remaining number of elements.
func (*Ring[T]) Gets ¶
Gets acquires elements from the circular queue and appends then into v, return the number of elements acquired and remained.
func (*Ring[T]) Put ¶
Put puts element into the circular queue. Directly return if the queue is full.
Click to show internal directories.
Click to hide internal directories.