Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::ThreadSafeQueue< TType > Class Template Reference

Minimal mutex-protected FIFO deque wrapper. More...

#include <spk_thread_safe_queue.hpp>

Collaboration diagram for spk::ThreadSafeQueue< TType >:
Collaboration graph

Public Types

using value_type = TType
 Element type stored by the queue.

Public Member Functions

void insert (TType &&p_value)
 Inserts a new element by move.
void insert (const TType &p_value)
 Inserts a new element by copy.
TType popFront ()
 Pops the front element.
TType popBack ()
 Pops the back element.
bool empty () const noexcept
 Checks whether the queue is empty.

Detailed Description

template<typename TType>
class spk::ThreadSafeQueue< TType >

Minimal mutex-protected FIFO deque wrapper.

Template Parameters
TTypestored element type; must be movable or copyable into the queue.
q.insert(42);
auto value = q.popFront();
Minimal mutex-protected FIFO deque wrapper.
Definition spk_thread_safe_queue.hpp:21
TType popFront()
Pops the front element.
Definition spk_thread_safe_queue.hpp:56
void insert(TType &&p_value)
Inserts a new element by move.
Definition spk_thread_safe_queue.hpp:35

Member Function Documentation

◆ empty()

template<typename TType>
bool spk::ThreadSafeQueue< TType >::empty ( ) const
inlinenoexcept

Checks whether the queue is empty.

Returns
true when no elements are stored.

◆ insert() [1/2]

template<typename TType>
void spk::ThreadSafeQueue< TType >::insert ( const TType & p_value)
inline

Inserts a new element by copy.

Parameters
p_valueValue to copy into the queue.

◆ insert() [2/2]

template<typename TType>
void spk::ThreadSafeQueue< TType >::insert ( TType && p_value)
inline

Inserts a new element by move.

Parameters
p_valueValue to move into the queue.

◆ popBack()

template<typename TType>
TType spk::ThreadSafeQueue< TType >::popBack ( )
inline

Pops the back element.

Returns
Moved-out element.
Exceptions
std::runtime_errorwhen the queue is empty.

◆ popFront()

template<typename TType>
TType spk::ThreadSafeQueue< TType >::popFront ( )
inline

Pops the front element.

Returns
Moved-out element.
Exceptions
std::runtime_errorwhen the queue is empty.

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