OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::blocking_queue_internal< T, Q > Class Template Reference

Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers. More...

#include <blocking_queue.hpp>

Inheritance diagram for cbdc::blocking_queue_internal< T, Q >:

Public Member Functions

 blocking_queue_internal ()=default
 
 blocking_queue_internal (const blocking_queue_internal &)=delete
 
auto operator= (const blocking_queue_internal &) -> blocking_queue_internal &=delete
 
 blocking_queue_internal (blocking_queue_internal &&)=delete
 
auto operator= (blocking_queue_internal &&) -> blocking_queue_internal &=delete
 
 ~blocking_queue_internal ()
 Destructor.
 
auto push (const T &item) -> size_t
 Pushes an element onto the queue and notifies at most one waiting consumer.
 
auto pop (T &item) -> bool
 Pops an element from the queue.
 
void clear ()
 Clears the queue and unblocks waiting consumers.
 
void reset ()
 Removes the wakeup flag for consumers.
 

Detailed Description

template<typename T, typename Q>
class cbdc::blocking_queue_internal< T, Q >

Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers.

Template Parameters
typeof object stored in the queue.

Definition at line 19 of file blocking_queue.hpp.

Constructor & Destructor Documentation

◆ blocking_queue_internal() [1/3]

template<typename T , typename Q >
cbdc::blocking_queue_internal< T, Q >::blocking_queue_internal ( )
default

◆ blocking_queue_internal() [2/3]

template<typename T , typename Q >
cbdc::blocking_queue_internal< T, Q >::blocking_queue_internal ( const blocking_queue_internal< T, Q > & )
delete

◆ blocking_queue_internal() [3/3]

template<typename T , typename Q >
cbdc::blocking_queue_internal< T, Q >::blocking_queue_internal ( blocking_queue_internal< T, Q > && )
delete

◆ ~blocking_queue_internal()

template<typename T , typename Q >
cbdc::blocking_queue_internal< T, Q >::~blocking_queue_internal ( )
inline

Destructor.

Clears the queue and unblocks any waiting consumers.

Definition at line 34 of file blocking_queue.hpp.

References cbdc::blocking_queue_internal< T, Q >::clear().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

template<typename T , typename Q >
void cbdc::blocking_queue_internal< T, Q >::clear ( )
inline

Clears the queue and unblocks waiting consumers.

Definition at line 81 of file blocking_queue.hpp.

Referenced by cbdc::blocking_queue_internal< T, Q >::~blocking_queue_internal().

◆ operator=() [1/2]

template<typename T , typename Q >
auto cbdc::blocking_queue_internal< T, Q >::operator= ( blocking_queue_internal< T, Q > && ) -> blocking_queue_internal &=delete
delete

◆ operator=() [2/2]

template<typename T , typename Q >
auto cbdc::blocking_queue_internal< T, Q >::operator= ( const blocking_queue_internal< T, Q > & ) -> blocking_queue_internal &=delete
delete

◆ pop()

template<typename T , typename Q >
auto cbdc::blocking_queue_internal< T, Q >::pop ( T & item) -> bool
inlinenodiscard

Pops an element from the queue.

Blocks if the queue is empty. Unblocks on destruction or clear without returning an element.

Parameters
itemobject into which to move the popped element.
Returns
true on success, false if interrupted by clear() or destruction.

Definition at line 59 of file blocking_queue.hpp.

◆ push()

template<typename T , typename Q >
auto cbdc::blocking_queue_internal< T, Q >::push ( const T & item) -> size_t
inline

Pushes an element onto the queue and notifies at most one waiting consumer.

Parameters
itemobject to push onto the queue.

Definition at line 41 of file blocking_queue.hpp.

◆ reset()

template<typename T , typename Q >
void cbdc::blocking_queue_internal< T, Q >::reset ( )
inline

Removes the wakeup flag for consumers.

Must be called after clear() before re-using the queue. All consumers must have returned from pop() before calling this method.

Definition at line 93 of file blocking_queue.hpp.


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