The Nebula Device 3: Threading::SafePriorityQueue< PRITYPE, TYPE > Class Template Reference

The Nebula Device 3

Threading::SafePriorityQueue< PRITYPE, TYPE > Class Template Reference

#include <safepriorityqueue.h>

Inheritance diagram for Threading::SafePriorityQueue< PRITYPE, TYPE >:

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

Detailed Description

template<class PRITYPE, class TYPE>
class Threading::SafePriorityQueue< PRITYPE, TYPE >

A thread-safe priority-sorted queue which protects itself with critical sections. Offers a method to wait for new elements to be added. Useful for inter-thread communications.

(C) 2006 Radon Labs GmbH


Public Member Functions

 SafePriorityQueue ()
 constructor
 SafePriorityQueue (const SafePriorityQueue< PRITYPE, TYPE > &rhs)
 copy constructor
void operator= (const SafePriorityQueue< PRITYPE, 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 Insert (PRITYPE pri, const TYPE &e)
 add element to the back of the queue
void EraseMatchingElements (const TYPE &e)
 erase all matching elements
TYPE Dequeue ()
 remove the element from the front of the queue
TYPE Peek () const
 get copy of 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

Protected Member Functions

Util::KeyValuePair< PRITYPE,
TYPE > & 
operator[] (IndexT index) const
 access element by index, 0 is the frontmost element (next to be dequeued)
bool operator== (const Queue< Util::KeyValuePair< PRITYPE, TYPE > > &rhs) const
 equality operator
bool operator!= (const Queue< Util::KeyValuePair< PRITYPE, TYPE > > &rhs) const
 inequality operator
void Reserve (SizeT num)
 increase capacity to fit N more elements into the queue
bool Contains (const Util::KeyValuePair< PRITYPE, TYPE > &e) const
 return true if queue contains element
void Enqueue (const Util::KeyValuePair< PRITYPE, TYPE > &e)
 add element to the back of the queue


Member Function Documentation

template<class PRITYPE, class TYPE>
void Threading::SafePriorityQueue< PRITYPE, TYPE >::Signal (  ) 

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.