All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::SynchronizedQueue< T > Class Template Reference

This class provides a thread-safe queue. More...

#include <Radiant/SynchronizedQueue.hpp>

Public Member Functions

bool empty () const
 Returns true if the queue is empty. More...
 
T & head ()
 Return a reference to the head item in the queue. More...
 
const T & head () const
 Return a reference to the head item in the queue. More...
 
SynchronizedQueue< T > & operator= (const SynchronizedQueue &c)
 Copies a queue. More...
 
pop ()
 Removes the head item in the queue and returns it. More...
 
void push (const T &t)
 Adds an element to the end of the queue. More...
 
 SynchronizedQueue ()
 Constructs an empty queue.
 
 SynchronizedQueue (const SynchronizedQueue &c)
 Constructs a copy of another queue. More...
 
bool testAndPop (T &result)
 Non-blocking call that returns false if the queue was empty. More...
 

Detailed Description

template<class T>
class Radiant::SynchronizedQueue< T >

This class provides a thread-safe queue.

Template Parameters
TType of the values stored

Constructor & Destructor Documentation

template<class T >
Radiant::SynchronizedQueue< T >::SynchronizedQueue ( const SynchronizedQueue< T > &  c)
inline

Constructs a copy of another queue.

Parameters
cqueue to copy

Member Function Documentation

template<class T >
bool Radiant::SynchronizedQueue< T >::empty ( ) const
inline

Returns true if the queue is empty.

Returns
True if queue is empty, true otherwise
template<class T >
T& Radiant::SynchronizedQueue< T >::head ( )
inline

Return a reference to the head item in the queue.

If the queue is empty, this function will block until something is pushed into it.

Returns
current head
template<class T >
const T& Radiant::SynchronizedQueue< T >::head ( ) const
inline

Return a reference to the head item in the queue.

If the queue is empty, this function will block until something is pushed into it.

Returns
current head
template<class T >
SynchronizedQueue<T>& Radiant::SynchronizedQueue< T >::operator= ( const SynchronizedQueue< T > &  c)
inline

Copies a queue.

Parameters
cQueue to copy
Returns
Reference to self
template<class T >
T Radiant::SynchronizedQueue< T >::pop ( )
inline

Removes the head item in the queue and returns it.

If the queue is empty, the function will block until something is pushed into it.

Returns
the current head of the queue
template<class T >
void Radiant::SynchronizedQueue< T >::push ( const T &  t)
inline

Adds an element to the end of the queue.

Parameters
tValue to add to the queue
template<class T >
bool Radiant::SynchronizedQueue< T >::testAndPop ( T &  result)
inline

Non-blocking call that returns false if the queue was empty.

Otherwise pops the head and assigns it to result.

Parameters
resulthead of the queue
Returns
returns true if the queue is was not empty and result was assigned, otherwise false