Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ThreadMessageQueue Class Template Reference

A FIFO for communication between threads. More...

#include <ThreadMessageQueue.h>

List of all members.

Public Methods

 ThreadMessageQueue ()
 Create the queue. More...

 ~ThreadMessageQueue ()
 Delete the queue structure, but all objects that are inside the queue are not deleted. More...

void add (T *object)
 Add an object to the queue. More...

T * getNext ()
 Get the next object in the queue. More...

bool isEmpty ()
 Returns true if the queue is empty. More...

int getLength ()
 Return the number of elements in the queue. More...

void print (std::ostream &)
 Print the contents of the Queue to the specified output stream. More...


Private Attributes

std::list< T *> m_queue
Condition m_ready
Mutex m_lock


Detailed Description

template<class T>
class ThreadMessageQueue< T >

A FIFO for communication between threads.

If the queue is empty, and you call getNext(), it will block. It is thread safe to add and remove from the queue at the same time.

Definition at line 10 of file ThreadMessageQueue.h.


Constructor & Destructor Documentation

template<class T>
ThreadMessageQueue< T >::ThreadMessageQueue
 

Create the queue.

Definition at line 43 of file ThreadMessageQueue.h.

template<class T>
ThreadMessageQueue< T >::~ThreadMessageQueue
 

Delete the queue structure, but all objects that are inside the queue are not deleted.

Definition at line 52 of file ThreadMessageQueue.h.


Member Function Documentation

template<class T>
void ThreadMessageQueue< T >::add T * object [inline]
 

Add an object to the queue.

Definition at line 63 of file ThreadMessageQueue.h.

Referenced by PriorityPacketQueue::add(), VisualizerFrame::addMessage(), SendWindow::initialSegmentation(), ReceiveWindow::reassemble(), SendWindow::reliableSend(), ServiceTable::signalListenComplete(), and ServiceTable::~ServiceTable().

template<class T>
int ThreadMessageQueue< T >::getLength [inline]
 

Return the number of elements in the queue.

Definition at line 105 of file ThreadMessageQueue.h.

template<class T>
T * ThreadMessageQueue< T >::getNext [inline]
 

Get the next object in the queue.

If the queue is empty, it will block until it receives something.

Definition at line 76 of file ThreadMessageQueue.h.

Referenced by VisualizerFrame::calculateNodes(), PriorityPacketQueue::getNext(), ServiceTable::listenService(), ReceiveWindow::reassemble(), and SendWindow::reliableSend().

template<class T>
bool ThreadMessageQueue< T >::isEmpty [inline]
 

Returns true if the queue is empty.

Definition at line 95 of file ThreadMessageQueue.h.

Referenced by VisualizerFrame::calculateNodes(), PriorityPacketQueue::getNext(), PriorityPacketQueue::isEmpty(), ReceiveWindow::reassemble(), and SendWindow::reliableSend().

template<class T>
void ThreadMessageQueue< T >::print std::ostream & out
 

Print the contents of the Queue to the specified output stream.

Definition at line 115 of file ThreadMessageQueue.h.

Referenced by PriorityPacketQueue::print().


Member Data Documentation

template<class T>
Mutex ThreadMessageQueue::m_lock [private]
 

Definition at line 24 of file ThreadMessageQueue.h.

template<class T>
std::list<T*> ThreadMessageQueue::m_queue [private]
 

Definition at line 22 of file ThreadMessageQueue.h.

template<class T>
Condition ThreadMessageQueue::m_ready [private]
 

Definition at line 23 of file ThreadMessageQueue.h.


The documentation for this class was generated from the following file:
Generated at Thu Jul 11 13:31:59 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001