Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
Public Member Functions | Protected Attributes | List of all members
libff::concurrent_fifo_spsc< T > Class Template Reference

#include <concurrent_fifo.hpp>

Public Member Functions

 concurrent_fifo_spsc ()=delete
 
 concurrent_fifo_spsc (const concurrent_fifo_spsc &)=delete
 
concurrent_fifo_spscoperator= (const concurrent_fifo_spsc &)=delete
 
 concurrent_fifo_spsc (size_t capacity)
 
 ~concurrent_fifo_spsc ()
 
size_t capacity () const
 
T * try_enqueue_begin ()
 
T * enqueue_begin_wait ()
 
void enqueue_end ()
 
const T * try_dequeue_begin ()
 
const T * dequeue_begin_wait ()
 
void dequeue_end ()
 

Protected Attributes

const size_t _capacity
 
T *const _buffer
 
size_t _producer_next_idx
 
std::atomic< size_t > _producer_num_produced
 
size_t _consumer_next_idx
 
std::atomic< size_t > _consumer_num_consumed
 

Detailed Description

template<typename T>
class libff::concurrent_fifo_spsc< T >

Simple lock-less single-producer, single-consumer fifo buffer. Exposes the raw read/write location directly, in way that the producer can know if the destination memory is available BEFORE he begins data production. In particular, if T = void *, say, the producer can recycle the buffer pointed to by the void * once try_enqueue_begin() succeeds.

Definition at line 23 of file concurrent_fifo.hpp.

Constructor & Destructor Documentation

◆ concurrent_fifo_spsc() [1/3]

template<typename T >
libff::concurrent_fifo_spsc< T >::concurrent_fifo_spsc ( )
delete

◆ concurrent_fifo_spsc() [2/3]

template<typename T >
libff::concurrent_fifo_spsc< T >::concurrent_fifo_spsc ( const concurrent_fifo_spsc< T > &  )
delete

◆ concurrent_fifo_spsc() [3/3]

template<typename T >
libff::concurrent_fifo_spsc< T >::concurrent_fifo_spsc ( size_t  capacity)

◆ ~concurrent_fifo_spsc()

template<typename T >
libff::concurrent_fifo_spsc< T >::~concurrent_fifo_spsc ( )

Member Function Documentation

◆ capacity()

template<typename T >
size_t libff::concurrent_fifo_spsc< T >::capacity ( ) const

◆ dequeue_begin_wait()

template<typename T >
const T* libff::concurrent_fifo_spsc< T >::dequeue_begin_wait ( )

Call try_dequeue_begin() until it succeeds. The caller should be sure that a producer will produce an element.

◆ dequeue_end()

template<typename T >
void libff::concurrent_fifo_spsc< T >::dequeue_end ( )

◆ enqueue_begin_wait()

template<typename T >
T* libff::concurrent_fifo_spsc< T >::enqueue_begin_wait ( )

Call try_enqueue_begin() until it succeeds. The caller should be sure that a consumer is active, to avoid the fifo being permanently blocked.

◆ enqueue_end()

template<typename T >
void libff::concurrent_fifo_spsc< T >::enqueue_end ( )

◆ operator=()

template<typename T >
concurrent_fifo_spsc& libff::concurrent_fifo_spsc< T >::operator= ( const concurrent_fifo_spsc< T > &  )
delete

◆ try_dequeue_begin()

template<typename T >
const T* libff::concurrent_fifo_spsc< T >::try_dequeue_begin ( )

Consumer must call this until it succeeds (returns a non-null pointer), and then read data from the returned address, before calling dequeue_end().

◆ try_enqueue_begin()

template<typename T >
T* libff::concurrent_fifo_spsc< T >::try_enqueue_begin ( )

Producer must call this until it succeeds (returns a non-null pointer), and then write values at the returned address before calling enqueue_end().

Member Data Documentation

◆ _buffer

template<typename T >
T* const libff::concurrent_fifo_spsc< T >::_buffer
protected

Definition at line 60 of file concurrent_fifo.hpp.

◆ _capacity

template<typename T >
const size_t libff::concurrent_fifo_spsc< T >::_capacity
protected

Definition at line 58 of file concurrent_fifo.hpp.

◆ _consumer_next_idx

template<typename T >
size_t libff::concurrent_fifo_spsc< T >::_consumer_next_idx
protected

Definition at line 65 of file concurrent_fifo.hpp.

◆ _consumer_num_consumed

template<typename T >
std::atomic<size_t> libff::concurrent_fifo_spsc< T >::_consumer_num_consumed
protected

Definition at line 66 of file concurrent_fifo.hpp.

◆ _producer_next_idx

template<typename T >
size_t libff::concurrent_fifo_spsc< T >::_producer_next_idx
protected

Definition at line 62 of file concurrent_fifo.hpp.

◆ _producer_num_produced

template<typename T >
std::atomic<size_t> libff::concurrent_fifo_spsc< T >::_producer_num_produced
protected

Definition at line 63 of file concurrent_fifo.hpp.


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