Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer[K comparable, V any] struct { // contains filtered or unexported fields }
Buffer is a circular ring buffer stores the elements being transferred by the producers to the consumer. The monotonically increasing count of reads and writes allow indexing sequentially to the next element location based upon a power-of-two sizing.
The producers race to read the counts, check if there is available capacity, and if so then try once to CAS to the next write count. If the increment is successful then the producer lazily publishes the element. The producer does not retry or block when unsuccessful due to a failed CAS or the buffer being full.
The consumer reads the counts and takes the available elements. The clearing of the elements and the next read count are lazily set.
This implementation is striped to further increase concurrency.
func New ¶
func New[K comparable, V any](nodeManager *node.Manager[K, V]) *Buffer[K, V]
New creates a new lossy Buffer.
func (*Buffer[K, V]) Add ¶
func (b *Buffer[K, V]) Add(n node.Node[K, V]) *PolicyBuffers[K, V]
Add lazily publishes the item to the consumer.
item may be lost due to contention.
type PolicyBuffers ¶
type PolicyBuffers[K comparable, V any] struct { Returned []node.Node[K, V] }
PolicyBuffers is the set of buffers returned by the lossy buffer.