Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ringbuffer ¶
type Ringbuffer[T any] chan T
Ringbuffer is a fixed length FIFO queue that drops new items when full and allows non-blocking polling for new items with optional timeout
func NewRingBuffer ¶
func NewRingBuffer[T any](size int) Ringbuffer[T]
NewRingbuffer creates a new ringbuffer with the given fixed number of items.
func (Ringbuffer[T]) Cap ¶
func (r Ringbuffer[T]) Cap() int
Cap returns the capacity of the ringbuffer.
func (Ringbuffer[T]) Get ¶
func (r Ringbuffer[T]) Get() T
Get gets an item from the ringbuffer, or blocks until one is available.
func (Ringbuffer[T]) Len ¶
func (r Ringbuffer[T]) Len() int
Len returns the number of items in the ringbuffer.
func (Ringbuffer[T]) Offer ¶
func (r Ringbuffer[T]) Offer(input T) bool
Offer adds an item to the ringbuffer. If the buffer is full, it returns immediately. Returns true if added.
Click to show internal directories.
Click to hide internal directories.