Archon::Utilities::Condition Struct Reference

A condition queue for implementing thread synchronization. More...

#include <archon/util/condition.H>

Collaboration diagram for Archon::Utilities::Condition:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Condition (Mutex &m)
 ~Condition ()
void notifyOne ()
void notifyAll ()
void wait () throw (UnexpectedException)
 NOTE: The mutex associated with this condition MUST ALWAYS be aquired by YOU when you call this method.
bool timedWait (Time timeout) throw (UnexpectedException)
 NOTE: The mutex associated with this condition MUST ALWAYS be aquired by YOU when you call this method.
int select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, Time timeout) throw (UnexpectedException)

Detailed Description

A condition queue for implementing thread synchronization.

Definition at line 49 of file condition.H.


Member Function Documentation

int Archon::Utilities::Condition::select int  n,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
Time  timeout
throw (UnexpectedException)
 

DON'T FORGET!

This method suspends the calling thread until one of the following event occur: Any event that would resume 'timedWait' on this condition and any event that would resume the system call pselect(n, readfds, writefds, exceptfds, 0, 0).

The first four arguments behave exactly as for the POSIX 1003.1-2001 systemcall 'pselect'.

Returns:
A positive value has the same meaning as the POSIX 1003.1-2001 systemcall 'pselect'. Zero means that it times out, and -1 means that it was awoken by a signal - proberbly due to somebody that called this->notifyAll().
See also:
Time

Definition at line 138 of file condition.C.

References Archon::Utilities::Mutex::lock(), m, Archon::SaiTestApps::Filebrowser::mutex, n, Archon::Utilities::Time::now(), Archon::Utilities::Thread::self(), and Archon::Utilities::Mutex::unlock().

Referenced by T::main().

bool Archon::Utilities::Condition::timedWait Time  timeout  )  throw (UnexpectedException)
 

NOTE: The mutex associated with this condition MUST ALWAYS be aquired by YOU when you call this method.

DON'T FORGET!

Like 'wait()' except that when the 'timeout' is reached the waiting is aborted. Note the 'timeout' is an absolute time value and not a delay.

Returns:
True if the timeout has been reached and false if the condition was signalled. Also, false is returned when the waiting is interrupted by a UNIX system signal.
See also:
Time

Definition at line 79 of file condition.C.

References Archon::Utilities::Mutex::mutex, Archon::SaiTestApps::Filebrowser::mutex, and Archon::Utilities::Thread::self().

Referenced by Archon::X3D::SAI::Session::ExternalEventQueue::main(), Archon::Utilities::Thread::sleep(), and Archon::Utilities::Thread::sleepUntil().

void Archon::Utilities::Condition::wait  )  throw (UnexpectedException)
 

NOTE: The mutex associated with this condition MUST ALWAYS be aquired by YOU when you call this method.

DON'T FORGET!

Note that there is generally no guarantee that the condition waited for is fulfilled upon return from this method. Therefore you must always re-check the condition again and repat the wait until you discover that the condition is fulfilled. Hopefully you knew this already.

Definition at line 57 of file condition.C.

References Archon::Utilities::Mutex::mutex, Archon::SaiTestApps::Filebrowser::mutex, and Archon::Utilities::Thread::self().

Referenced by Archon::Utilities::Semaphore::down(), Archon::X3D::SAI::Session::ExternalEventQueue::flush(), Archon::SaiTestApps::Textviewer::main(), Archon::SaiTestApps::Filebrowser::main(), Archon::Utilities::Stream::BasicPipe< char >::read(), Archon::Render::Conductor::render(), Archon::Utilities::Thread::wait(), Archon::Utilities::Job::Queue::wait(), Archon::Utilities::Stream::BasicPipe< char >::write(), Archon::Utilities::Web::DefaultClient::~DefaultClient(), and Archon::Utilities::Job::Queue::~Queue().


The documentation for this struct was generated from the following files:
Generated on Sun Jul 30 22:57:20 2006 for Archon by  doxygen 1.4.4