Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::SpscRingBuffer< T, Capacity > Class Template Reference

Lock-free single-producer single-consumer (SPSC) bounded ring buffer. More...

#include <streaming_sink.hpp>

Public Member Functions

 SpscRingBuffer ()
 Construct an empty ring buffer.
 
 SpscRingBuffer (const SpscRingBuffer &)=delete
 
SpscRingBufferoperator= (const SpscRingBuffer &)=delete
 
bool push (T item)
 Push a single item. Returns false if the buffer is full.
 
size_t push (const T *items, size_t count)
 Bulk push up to count items. Returns the number actually pushed.
 
bool pop (T &out)
 Pop a single item into out. Returns false if the buffer is empty.
 
size_t pop (T *out, size_t max_count)
 Bulk pop up to max_count items into out. Returns number popped.
 
size_t size () const
 Approximate number of items currently in the buffer.
 
bool empty () const
 True if the buffer appears empty (approximate, no lock).
 
bool full () const
 True if the buffer appears full (approximate, no lock).
 

Static Public Member Functions

static constexpr size_t capacity ()
 The compile-time capacity of this ring buffer.
 

Detailed Description

template<typename T, size_t Capacity>
class signet::forge::SpscRingBuffer< T, Capacity >

Lock-free single-producer single-consumer (SPSC) bounded ring buffer.

Uses acquire/release atomic ordering on head and tail pointers for wait-free push/pop. Capacity must be a power of two (enforced by static_assert).

Template Parameters
TElement type (must be move-constructible).
CapacityMaximum number of elements (must be power of 2). Effective capacity is Capacity - 1.

Definition at line 132 of file streaming_sink.hpp.

Constructor & Destructor Documentation

◆ SpscRingBuffer() [1/2]

template<typename T , size_t Capacity>
signet::forge::SpscRingBuffer< T, Capacity >::SpscRingBuffer ( )
inline

Construct an empty ring buffer.

Definition at line 138 of file streaming_sink.hpp.

◆ SpscRingBuffer() [2/2]

template<typename T , size_t Capacity>
signet::forge::SpscRingBuffer< T, Capacity >::SpscRingBuffer ( const SpscRingBuffer< T, Capacity > &  )
delete

Member Function Documentation

◆ capacity()

template<typename T , size_t Capacity>
static constexpr size_t signet::forge::SpscRingBuffer< T, Capacity >::capacity ( )
inlinestaticconstexpr

The compile-time capacity of this ring buffer.

Definition at line 220 of file streaming_sink.hpp.

◆ empty()

template<typename T , size_t Capacity>
bool signet::forge::SpscRingBuffer< T, Capacity >::empty ( ) const
inline

True if the buffer appears empty (approximate, no lock).

Definition at line 215 of file streaming_sink.hpp.

◆ full()

template<typename T , size_t Capacity>
bool signet::forge::SpscRingBuffer< T, Capacity >::full ( ) const
inline

True if the buffer appears full (approximate, no lock).

Definition at line 217 of file streaming_sink.hpp.

◆ operator=()

template<typename T , size_t Capacity>
SpscRingBuffer & signet::forge::SpscRingBuffer< T, Capacity >::operator= ( const SpscRingBuffer< T, Capacity > &  )
delete

◆ pop() [1/2]

template<typename T , size_t Capacity>
bool signet::forge::SpscRingBuffer< T, Capacity >::pop ( T &  out)
inline

Pop a single item into out. Returns false if the buffer is empty.

Definition at line 177 of file streaming_sink.hpp.

◆ pop() [2/2]

template<typename T , size_t Capacity>
size_t signet::forge::SpscRingBuffer< T, Capacity >::pop ( T *  out,
size_t  max_count 
)
inline

Bulk pop up to max_count items into out. Returns number popped.

Definition at line 190 of file streaming_sink.hpp.

◆ push() [1/2]

template<typename T , size_t Capacity>
size_t signet::forge::SpscRingBuffer< T, Capacity >::push ( const T *  items,
size_t  count 
)
inline

Bulk push up to count items. Returns the number actually pushed.

Definition at line 163 of file streaming_sink.hpp.

◆ push() [2/2]

template<typename T , size_t Capacity>
bool signet::forge::SpscRingBuffer< T, Capacity >::push ( item)
inline

Push a single item. Returns false if the buffer is full.

Definition at line 149 of file streaming_sink.hpp.

◆ size()

template<typename T , size_t Capacity>
size_t signet::forge::SpscRingBuffer< T, Capacity >::size ( ) const
inline

Approximate number of items currently in the buffer.

Definition at line 208 of file streaming_sink.hpp.


The documentation for this class was generated from the following file: