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

Condition Class Reference

#include <Condition.h>

List of all members.

Public Methods

 Condition ()
 Condition (const Condition &c)
 ~Condition ()
int wait ()
int wait (Mutex *mutex)
int timedWait (Mutex *mutex, const struct timespec *timeToWait)
bool timedWait (Mutex *mutex, int milli)
int broadcast ()
int signal ()

Protected Attributes

pthread_cond_t m_condition


Detailed Description

Wraps a pthread condition variable. This way you dont have to worry about creation and destruction of the pthread condition when you use it inside of classes. You can also create conditions in the global scope.

Definition at line 15 of file Condition.h.


Constructor & Destructor Documentation

Condition::Condition [inline]
 

Create and initialize a pthread condition variable.

Definition at line 21 of file Condition.h.

Condition::Condition const Condition & c [inline]
 

Copy a pthread condition variable.

Definition at line 29 of file Condition.h.

Condition::~Condition [inline]
 

Destory the pthread condition variable.

Definition at line 37 of file Condition.h.


Member Function Documentation

int Condition::broadcast [inline]
 

A wrapper around pthread_cond_broadcast().

Definition at line 94 of file Condition.h.

Referenced by LinkLayerInterface::accept(), LinkLayerInterface::connect(), and LinkLayerInterface::handleEvent().

int Condition::signal [inline]
 

A wrapper around pthread_cond_signal().

Definition at line 102 of file Condition.h.

Referenced by ThreadMessageQueue::add(), PriorityPacketQueue::add(), ReceiveWindow::addReceive(), ReceiveWindow::close(), LinkLayerInterface::closeLink(), ReceiveWindow::destroy(), SendWindow::end(), ReceiveWindow::getNext(), PriorityPacketQueue::getNext(), SendWindow::onAckRecvd(), SendWindow::reliableSend(), ServiceEntry::signalConnectComplete(), ServiceEntry::signalDisconnect(), LiveBroadcastTable::~LiveBroadcastTable(), NetworkLayer::~NetworkLayer(), and PriorityPacketQueue::~PriorityPacketQueue().

bool Condition::timedWait Mutex * mutex,
int milli
[inline]
 

A convenience function.

This calls pthread_cond_timedwait with the delay specified in milliseconds. Warning: if the mutex is NOT locked before you call this function, it will return immediately. The mutex MUST be locked!!!

Parameters:
mutex   Unlocks this mutex until cond is signaled.
milli   Number of milliseconds from now before timeout.
Returns:
true if the condition was signalled, false if the condtion was not signalled and the time has run out.

Definition at line 84 of file Condition.h.

int Condition::timedWait Mutex * mutex,
const struct timespec * timeToWait
[inline]
 

A wrapper around pthread_cond_timedwait().

Definition at line 67 of file Condition.h.

Referenced by ReceiveWindow::destroy(), NetworkLayer::discoveryThreadImpl(), SendWindow::end(), NetworkLayer::pingThreadImpl(), SendWindow::reliableSend(), Timer::timerThreadImpl(), ServiceEntry::waitForConnectComplete(), ServiceEntry::waitForDisconnect(), and PriorityPacketQueue::~PriorityPacketQueue().

int Condition::wait Mutex * mutex [inline]
 

A wrapper around pthread_cond_wait().

Definition at line 59 of file Condition.h.

int Condition::wait [inline]
 

Wait on the specified condition variable to be signalled. Use this when you dont care about locking or unlocking a mutex along with the condition variable.

Returns only when the variable has been signalled.

Definition at line 49 of file Condition.h.

Referenced by ThreadMessageQueue::getNext(), ReceiveWindow::getNext(), PriorityPacketQueue::getNext(), LinkLayerInterface::listenImpl(), LinkLayerInterface::peerConnectImpl(), LinkLayerInterface::pollAllSocketsImpl(), and Timer::timerThreadImpl().


Member Data Documentation

pthread_cond_t Condition::m_condition [protected]
 

Definition at line 107 of file Condition.h.


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