The Nebula Device 3: Threading::SafeQueue< TYPE > Class Template Reference

The Nebula Device 3

Threading::SafeQueue< TYPE > Class Template Reference

#include <safequeue.h>

Inheritance diagram for Threading::SafeQueue< TYPE >:

< TYPE >_map" border="0" alt="">
< TYPE >_map"> Util::Queue< TYPE >< TYPE >" shape="rect" coords="0,0,195,24">


Detailed Description

template<class TYPE>
class Threading::SafeQueue< TYPE >

Thread-safe version of Util::Queue.

(C) 2007 Radon Labs GmbH


Public Member Functions

 SafeQueue ()
 constructor
 SafeQueue (const SafeQueue< TYPE > &rhs)
 copy constructor
void operator= (const SafeQueue< TYPE > &rhs)
 assignment operator
SizeT Size () const
 returns number of elements in the queue
bool IsEmpty () const
 return true if queue is empty
void Clear ()
 remove all elements from the queue
void Enqueue (const TYPE &e)
 add element to the back of the queue
TYPE Dequeue ()
 remove the element from the front of the queue
Util::Array< TYPE > DequeueAll ()
 dequeue all events (only requires one lock)
TYPE Peek () const
 access to element at front of queue without removing it
void Wait ()
 wait until queue contains at least one element
void Signal ()
 signal the internal event, so that Wait() will return
void EraseMatchingElements (const TYPE &e)
 erase all matching elements

Protected Member Functions

TYPE & operator[] (IndexT index) const
 access element by index, 0 is the frontmost element (next to be dequeued)
bool operator== (const Queue< TYPE > &rhs) const
 equality operator
bool operator!= (const Queue< TYPE > &rhs) const
 inequality operator
bool Contains (const TYPE &e) const
 return true if queue contains element


Member Function Documentation

template<class TYPE>
void Threading::SafeQueue< TYPE >::Signal (  )  [inline]

signal the internal event, so that Wait() will return

This signals the internal event object, on which Wait() may be waiting. This method may be useful to wake up a thread waiting for events when it should stop.