Documentation ¶
Index ¶
Constants ¶
const CacheLinePadSize = unsafe.Sizeof(cpu.CacheLinePad{})
CacheLinePadSize represents the CPU Cache Line Padding Size, compliant with the current running CPU Architect
const MaxUint32 = ^uint32(0)
MaxUint32 represents the maximal uint32 value
const MaxUint32_64 = uint64(^uint32(0))
MaxUint32_64 represents the maximal uint32 value
const MaxUint64 = ^uint64(0)
MaxUint64 represents the maximal uint64 value
Variables ¶
var ErrQueueEmpty error
ErrQueueEmpty queue empty when dequeueing
var ErrQueueFull error
ErrQueueFull queue full when enqueueing
var ErrQueueNotReady error
ErrQueueNotReady queue not ready for enqueue or dequeue
var ErrRaced error
ErrRaced the exception raised if data racing
Functions ¶
This section is empty.
Types ¶
type Dbg ¶
type Dbg interface { GetGetWaits() uint64 GetPutWaits() uint64 Debug(enabled bool) (lastState bool) ResetCounters() }
Dbg exposes some internal fields for debugging
type Initializeable ¶
type Initializeable[T any] interface { PreAlloc(index int) (newBlock T) CloneIn(srcBlock T, targetBlock *T) CloneOut(srcBlock *T) (targetBlock T) }
Initializeable data item supports lighter-weight clone operations.
type Opt ¶
type Opt[T any] func(rb *ringBuf[T])
Opt interface the functional options
func WithDebugMode ¶
WithDebugMode enables the internal debug mode for more logging output, and collect the metrics for debugging
func WithItemInitializer ¶
func WithItemInitializer[T any](initializeable Initializeable[T]) Opt[T]
WithItemInitializer provides your custom initializer for each data item.
type Queue ¶
type Queue[T any] interface { Enqueue(item T) (err error) Dequeue() (item T, err error) // Cap returns the outer capacity of the ring buffer. Cap() uint32 // CapReal returns the real (inner) capacity of the ring buffer. CapReal() uint32 // Size returns the quantity of items in the ring buffer queue Size() uint32 IsEmpty() (b bool) IsFull() (b bool) Reset() }
Queue interface provides a set of standard queue operations
type RingBuffer ¶
type RingBuffer[T any] interface { Close() Enqueue(item T) (err error) Dequeue() (item T, err error) // Cap returns the outer capacity of the ring buffer. Cap() uint32 // CapReal returns the real (inner) capacity of the ring buffer. CapReal() uint32 // Size returns the quantity of items in the ring buffer queue Size() uint32 IsEmpty() (b bool) IsFull() (b bool) Reset() Put(item T) (err error) Get() (item T, err error) // Quantity returns the quantity of items in the ring buffer queue Quantity() uint32 Debug(enabled bool) (lastState bool) ResetCounters() }
RingBuffer interface provides a set of standard ring buffer operations