ringbuffer

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[Value any](opts ...options.Option[RingBuffer[Value]]) core.Queue[Value]

New creates a new RingBuffer

func WithCapacity added in v0.0.2

func WithCapacity[Value any](c int) options.Option[RingBuffer[Value]]

func WithOverride added in v0.0.2

func WithOverride[Value any]() options.Option[RingBuffer[Value]]

Types

type RingBuffer

type RingBuffer[Value any] struct {
	// contains filtered or unexported fields
}

RingBuffer is a lock-free queue implementation based on a ring buffer.

func (*RingBuffer[Value]) Dequeue

func (rb *RingBuffer[Value]) Dequeue() (Value, bool)

Pop reads the next item in the buffer. We retry in case of some conflict with other goroutine.

func (*RingBuffer[Value]) Empty

func (rb *RingBuffer[Value]) Empty() bool

func (*RingBuffer[Value]) Enqueue

func (rb *RingBuffer[Value]) Enqueue(v Value) bool

Push adds a new item to the buffer. We revert changes and retry in case of some conflict with other goroutine.

func (*RingBuffer[Value]) Full

func (rb *RingBuffer[Value]) Full() bool

func (*RingBuffer[Value]) Size

func (rb *RingBuffer[Value]) Size() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL