KASKADE 7 development version
Loading...
Searching...
No Matches
Kaskade::ConcurrentQueue< T > Class Template Reference

A concurrent fifo queue. More...

#include <threading.hh>

Public Member Functions

 ConcurrentQueue ()
 Constructs an empty queue.
 ConcurrentQueue (ConcurrentQueue &&q)
 Moves a queue.
ConcurrentQueue & operator= (ConcurrentQueue const &q)
 Assignment.
bool empty () const
size_t size () const
 Returns the number of tasks waiting.
void push_back (T &&t)
 Stores an element at the end of the queue.
T pop_front ()
 Retrieves the foremost element.
int running (int n)
 Change the number of running worker threads.
int running () const
 Get the number of running worker threads.

Detailed Description

template<class T>
class Kaskade::ConcurrentQueue< T >

A concurrent fifo queue.

The queue is not copyable as it is intended to hold non-copyable std:packaged_task objects.

Definition at line 134 of file threading.hh.

Constructor & Destructor Documentation

◆ ConcurrentQueue() [1/2]

template<class T>
Kaskade::ConcurrentQueue< T >::ConcurrentQueue ( )
inline

Constructs an empty queue.

Definition at line 139 of file threading.hh.

Referenced by ConcurrentQueue(), and operator=().

◆ ConcurrentQueue() [2/2]

template<class T>
Kaskade::ConcurrentQueue< T >::ConcurrentQueue ( ConcurrentQueue< T > && q)
inline

Moves a queue.

This transferres all tasks waiting in q to the newly constructed queue, but leaves q intact.

Definition at line 149 of file threading.hh.

Member Function Documentation

◆ empty()

template<class T>
bool Kaskade::ConcurrentQueue< T >::empty ( ) const
inline

Definition at line 167 of file threading.hh.

◆ operator=()

template<class T>
ConcurrentQueue & Kaskade::ConcurrentQueue< T >::operator= ( ConcurrentQueue< T > const & q)
inline

Assignment.

This copies all tasks waiting in q to the newly constructed queue, but leaves q intact.

Definition at line 160 of file threading.hh.

◆ pop_front()

template<class T>
T Kaskade::ConcurrentQueue< T >::pop_front ( )
inline

Retrieves the foremost element.

This method blocks if the queue is empty and waits for data to become available.

Definition at line 201 of file threading.hh.

◆ push_back()

template<class T>
void Kaskade::ConcurrentQueue< T >::push_back ( T && t)
inline

Stores an element at the end of the queue.

Definition at line 187 of file threading.hh.

◆ running() [1/2]

template<class T>
int Kaskade::ConcurrentQueue< T >::running ( ) const
inline

Get the number of running worker threads.

Returns
the number of running worker threads

Definition at line 233 of file threading.hh.

◆ running() [2/2]

template<class T>
int Kaskade::ConcurrentQueue< T >::running ( int n)
inline

Change the number of running worker threads.

Parameters
nif 1, increment the number of running workers, if -1, decrement it.
Returns
the number of running worker threads

Definition at line 222 of file threading.hh.

◆ size()

template<class T>
size_t Kaskade::ConcurrentQueue< T >::size ( ) const
inline

Returns the number of tasks waiting.

Definition at line 177 of file threading.hh.


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