KASKADE 7 development version
Public Member Functions | List of all members
Kaskade::ConcurrentQueue< T > Class Template Reference

A concurrent fifo queue. More...

#include <threading.hh>

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 131 of file threading.hh.

Public Member Functions

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

Constructor & Destructor Documentation

◆ ConcurrentQueue() [1/2]

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

Constructs an empty queue.

Definition at line 136 of file threading.hh.

◆ 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 146 of file threading.hh.

Member Function Documentation

◆ empty()

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

Definition at line 164 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 157 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 198 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 184 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 230 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 219 of file threading.hh.

Referenced by Kaskade::NumaThreadPool::runningOnGlobalQueue().

◆ size()

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

Returns the number of tasks waiting.

Definition at line 174 of file threading.hh.


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