ThreadSafeQueue< T > Class Template Reference [Atlas Core]

#include <threadSafeQueue.h>

Inheritance diagram for ThreadSafeQueue< T >:

Inheritance graph
[legend]
List of all members.

Detailed Description


template<class T> class ThreadSafeQueue< T >

A simple thread-safe queue.


Public Member Functions

 ThreadSafeQueue ()
 ~ThreadSafeQueue ()
void queue (const T &data)
 Add new item to end of queue.
bool dequeue (T &res)
 Dequeue an item from the front of the queue.
void clear ()
 Remove all items from the queue.
void sort (int(*compareFunc)(const T *a, const T *b))
 Sort everything in the queue using the provided qsort-compatible function.
Vector< T > & lockVector ()
 Lock the vector for direct access.
void unlockVector ()
 Unlock the vector once we're done with it.

Private Attributes

voidmMutex
Vector< T > mQueue
volatile bool mLocked


Constructor & Destructor Documentation

template<class T>
ThreadSafeQueue< T >::ThreadSafeQueue (  )  [inline]

template<class T>
ThreadSafeQueue< T >::~ThreadSafeQueue (  )  [inline]


Member Function Documentation

template<class T>
void ThreadSafeQueue< T >::queue ( const T &  data  )  [inline]

Add new item to end of queue.

template<class T>
bool ThreadSafeQueue< T >::dequeue ( T &  res  )  [inline]

Dequeue an item from the front of the queue.

template<class T>
void ThreadSafeQueue< T >::clear (  )  [inline]

Remove all items from the queue.

template<class T>
void ThreadSafeQueue< T >::sort ( int(*)(const T *a, const T *b)  compareFunc  )  [inline]

Sort everything in the queue using the provided qsort-compatible function.

template<class T>
Vector<T>& ThreadSafeQueue< T >::lockVector (  )  [inline]

Lock the vector for direct access.

template<class T>
void ThreadSafeQueue< T >::unlockVector (  )  [inline]

Unlock the vector once we're done with it.


Member Data Documentation

template<class T>
void* ThreadSafeQueue< T >::mMutex [private]

template<class T>
Vector<T> ThreadSafeQueue< T >::mQueue [private]

template<class T>
volatile bool ThreadSafeQueue< T >::mLocked [private]