Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
asyncpp::threadsafe_queue< T, Container > Class Template Reference

A threadsafe (mutex protected) queue. More...

#include <asyncpp/threadsafe_queue.h>

Public Member Functions

template<typename... Args>
 threadsafe_queue (Args &&... args)
 Construct a new queue.
 
 threadsafe_queue (const threadsafe_queue &other)
 
 threadsafe_queue (threadsafe_queue &&other)
 
threadsafe_queueoperator= (const threadsafe_queue &other)
 
threadsafe_queueoperator= (threadsafe_queue &&other)
 
std::optional< T > pop ()
 Pop the first element from the queue.
 
void push (T val)
 Push an element to the queue.
 
template<typename... Args>
void emplace (Args &&... args)
 Emplace a new element to the queue.
 

Detailed Description

template<typename T, typename Container = std::deque<T>>
class asyncpp::threadsafe_queue< T, Container >

A threadsafe (mutex protected) queue.

Template Parameters
TType of the contained elements
ContainerType of the container to use, defaults to std::deque<T>

Constructor & Destructor Documentation

◆ threadsafe_queue()

template<typename T , typename Container = std::deque<T>>
template<typename... Args>
asyncpp::threadsafe_queue< T, Container >::threadsafe_queue ( Args &&... args)
inlineexplicit

Construct a new queue.

Parameters
argsArguments to forward to the container constructor

Member Function Documentation

◆ emplace()

template<typename T , typename Container = std::deque<T>>
template<typename... Args>
void asyncpp::threadsafe_queue< T, Container >::emplace ( Args &&... args)
inline

Emplace a new element to the queue.

Parameters
argsArguments to forward to the element constructor

◆ pop()

template<typename T , typename Container = std::deque<T>>
std::optional< T > asyncpp::threadsafe_queue< T, Container >::pop ( )
inline

Pop the first element from the queue.

Returns
The first element of the queue or std::nullopt if the queue is empty.

◆ push()

template<typename T , typename Container = std::deque<T>>
void asyncpp::threadsafe_queue< T, Container >::push ( T val)
inline

Push an element to the queue.

Parameters
valThe element to push

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