Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEOF = errors.New("EOF")
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer[T any] struct { // contains filtered or unexported fields }
Buffer implements a generic Buffer that can store any type of data. It is not thread-safe and should be used with a mutex. It is used by LinkedBuffer to store data and is not intended to be used directly.
type LinkedBuffer ¶
type LinkedBuffer[T any] struct { // contains filtered or unexported fields }
LinkedBuffer implements an unbounded generic buffer that can be written to and read from concurrently. It is implemented using a linked list of buffers.
func NewLinkedBuffer ¶
func NewLinkedBuffer[T any](initialCapacity, maxCapacity int) *LinkedBuffer[T]
func (*LinkedBuffer[T]) Len ¶
func (b *LinkedBuffer[T]) Len() uint64
Len returns the number of elements in the buffer that haven't yet been read
func (*LinkedBuffer[T]) Read ¶
func (b *LinkedBuffer[T]) Read(values []T) int
Read reads values from the buffer and returns the number of elements read
func (*LinkedBuffer[T]) ReadCount ¶
func (b *LinkedBuffer[T]) ReadCount() uint64
ReadCount returns the number of elements read from the buffer since it was created
func (*LinkedBuffer[T]) Write ¶
func (b *LinkedBuffer[T]) Write(values []T)
Write writes values to the buffer
func (*LinkedBuffer[T]) WriteCount ¶
func (b *LinkedBuffer[T]) WriteCount() uint64
WriteCount returns the number of elements written to the buffer since it was created