Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferType ¶
type BufferType int
BufferType contains different type names of ring buffer
const ( // Classical ring buffer is a classical implementation of ring buffer Classical BufferType = iota // NodeBased is a type of ring buffer that implemented as node based, // see https://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue NodeBased )
type RingBuffer ¶
type RingBuffer[T any] interface { Offer(T) (success bool) Poll() (value T, success bool) SingleProducerOffer(valueSupplier func() (v T, finish bool)) SingleConsumerPoll(valueConsumer func(T)) SingleConsumerPollVec(ret []T) (validCnt uint64) }
RingBuffer defines the behavior of ring buffer
func New ¶
func New[T any](t BufferType, capacity uint64) RingBuffer[T]
New build a RingBuffer with BufferType and capacity. Expand capacity as power-of-two, to make head/tail calculate faster and simpler
Click to show internal directories.
Click to hide internal directories.