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

Multiple-producer single-consumer (MPSC) bounded ring buffer. More...

#include <streaming_sink.hpp>

Public Member Functions

 MpscRingBuffer ()
 Construct the ring buffer, initializing all slot sequences.
 
 MpscRingBuffer (const MpscRingBuffer &)=delete
 
MpscRingBufferoperator= (const MpscRingBuffer &)=delete
 
bool push (T item)
 Push one item. Returns false immediately if the buffer is full.
 
size_t push (const T *items, size_t count)
 Bulk push. Returns the number of items actually pushed.
 
bool pop (T &out)
 Pop one 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. Returns number popped.
 
size_t size () const
 Approximate number of items in the buffer (may transiently exceed Capacity during push).
 
bool empty () const
 True if the buffer appears empty (approximate).
 
bool full () const
 True if the buffer appears full (approximate).
 

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::MpscRingBuffer< T, Capacity >

Multiple-producer single-consumer (MPSC) bounded ring buffer.

Producers are lock-free via CAS on the enqueue position (Vyukov-style per-slot sequencing). The single consumer requires no locking. Capacity must be a power of two.

Template Parameters
TElement type (must be move-constructible and default-constructible).
CapacityMaximum number of elements (must be power of 2).

Definition at line 251 of file streaming_sink.hpp.

Constructor & Destructor Documentation

◆ MpscRingBuffer() [1/2]

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

Construct the ring buffer, initializing all slot sequences.

Definition at line 271 of file streaming_sink.hpp.

◆ MpscRingBuffer() [2/2]

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

Member Function Documentation

◆ capacity()

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

The compile-time capacity of this ring buffer.

Definition at line 372 of file streaming_sink.hpp.

◆ empty()

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

True if the buffer appears empty (approximate).

Definition at line 367 of file streaming_sink.hpp.

◆ full()

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

True if the buffer appears full (approximate).

Definition at line 369 of file streaming_sink.hpp.

◆ operator=()

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

◆ pop() [1/2]

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

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

Definition at line 331 of file streaming_sink.hpp.

◆ pop() [2/2]

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

Bulk pop up to max_count items. Returns number popped.

Definition at line 349 of file streaming_sink.hpp.

◆ push() [1/2]

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

Bulk push. Returns the number of items actually pushed.

Definition at line 317 of file streaming_sink.hpp.

◆ push() [2/2]

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

Push one item. Returns false immediately if the buffer is full.

Definition at line 286 of file streaming_sink.hpp.

◆ size()

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

Approximate number of items in the buffer (may transiently exceed Capacity during push).

Definition at line 362 of file streaming_sink.hpp.


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