MOTION  0.01
Framework for mixed-protocol multi-party computation
Public Member Functions | List of all members
encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType > Class Template Reference

#include <synchronized_queue.h>

Public Member Functions

 BasicSynchronizedQueue ()=default
 
 BasicSynchronizedQueue (BasicSynchronizedQueue &&other)=default
 
bool empty () const noexcept
 
bool IsClosed () const noexcept
 
bool IsClosedAndEmpty () const noexcept
 
void close () noexcept
 
void enqueue (const T &item)
 
void enqueue (T &&item)
 
std::optional< T > dequeue () noexcept
 
std::optional< std::queue< T > > BatchDequeue () noexcept
 

Detailed Description

template<typename T, typename MutexType, typename ConditionVariableType>
class encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >

Synchronized, closable queue for elements of type T.

The template is based on std::queue and provides synchronized operations such that items can be enqueued/dequeued by different threads. The queue can be customized with different synchronization primitives, e.g., std::mutex and fibers::mutex, via template parameters. Elements can be dequeued one-by-one (dequeue) or all at once (batch_dequeue). The queue can be closed which signals consumers that no further elements will be inserted. Dequeue operations return std::nullopt if the queue is closed and empty.

Constructor & Destructor Documentation

◆ BasicSynchronizedQueue() [1/2]

template<typename T , typename MutexType , typename ConditionVariableType >
encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::BasicSynchronizedQueue ( )
default

◆ BasicSynchronizedQueue() [2/2]

template<typename T , typename MutexType , typename ConditionVariableType >
encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::BasicSynchronizedQueue ( BasicSynchronizedQueue< T, MutexType, ConditionVariableType > &&  other)
default

Member Function Documentation

◆ BatchDequeue()

template<typename T , typename MutexType , typename ConditionVariableType >
std::optional<std::queue<T> > encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::BatchDequeue ( )
inlinenoexcept

Extract all elements of the queue.

◆ close()

template<typename T , typename MutexType , typename ConditionVariableType >
void encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::close ( )
inlinenoexcept

Close the queue.

◆ dequeue()

template<typename T , typename MutexType , typename ConditionVariableType >
std::optional<T> encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::dequeue ( )
inlinenoexcept

Extract an element from the queue.

◆ empty()

template<typename T , typename MutexType , typename ConditionVariableType >
bool encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::empty ( ) const
inlinenoexcept

Check if queue is empty.

◆ enqueue() [1/2]

template<typename T , typename MutexType , typename ConditionVariableType >
void encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::enqueue ( const T &  item)
inline

Add a new element to the queue.

◆ enqueue() [2/2]

template<typename T , typename MutexType , typename ConditionVariableType >
void encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::enqueue ( T &&  item)
inline

◆ IsClosed()

template<typename T , typename MutexType , typename ConditionVariableType >
bool encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::IsClosed ( ) const
inlinenoexcept

Check if queue is closed.

◆ IsClosedAndEmpty()

template<typename T , typename MutexType , typename ConditionVariableType >
bool encrypto::motion::BasicSynchronizedQueue< T, MutexType, ConditionVariableType >::IsClosedAndEmpty ( ) const
inlinenoexcept

Check if queue is closed and empty.


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