Main Page Namespace List Class Hierarchy Compound List Namespace Members Compound Members
Barrier Class Template Reference
#include <Barrier.h>
Inheritance diagram for Barrier:
List of all members.
Detailed Description
template<unsigned int Count, class LockType>
class ZThread::Barrier< Count, LockType >
- Author:
-
Eric Crahen <crahen@cse.buffalo.edu>
- Date:
-
<2002-06-02T08:11:27-0400>
- Version:
-
2.2.1
A Barrier is a Waitable object that serves as synchronization points for a set of threads. A Barrier is constructed for a fixed number (N) of threads. Threads attempting to wait() on a Barrier ( 1 - N) will block until the Nth thread arrives. The Nth thread will awaken all the the others.
An optional Runnable command may be associated with the Barrier. This will be run() when the Nth thread arrives and Barrier is not broken.
Error Checking
A Barrier uses an all-or-nothing. All threads invovled must successfully meet at Barrier. If any one of those threads leaves before all the threads have (as the result of an error or exception) then all threads present at the Barrier will throw BrokenBarrier_Exception.
A broken Barrier will cause all threads attempting to wait() on it to throw a BrokenBarrier_Exception.
A Barrier will remain 'broken', until it is manually reset().
Constructor & Destructor Documentation
|
Create a Barrier that executes the given Runnable object when all threads arrive. - Parameters:
-
|
Member Function Documentation
|
Reset the Barrier. - Exceptions:
-
- Postcondition:
-
the Barrier is no longer Broken and can be used again.
|
void shatter |
( |
|
) |
[inline] |
|
virtual bool wait |
( |
unsigned long |
timeout |
) |
[inline, virtual] |
|
|
Enter barrier and wait for the other threads. This can block for an definite amount of time, which is, at most, the length of the timeout. - Parameters:
-
timeout |
- maximum amount of time (milliseconds) this method could block |
- Returns :
-
bool true if the Barrier is successful before the time expires.
- Exceptions:
-
BrokenBarrier_Exception |
thrown when any of the thread that has left the Barrier as a result of an error or exception. |
Interrupted_Exception |
thrown when the calling thread is interupt()ed. A thread may be interrupted at any time, prematurely ending any wait. |
- See also:
-
Waitable::wait(unsigned long)
- Postcondition:
-
All threads have successfully arrived at the Barrier if no exception is thrown
Reimplemented from Waitable. |
virtual void wait |
( |
|
) |
[inline, virtual] |
|
|
Enter barrier and wait for the other threads. This can block for an indefinite amount of time. - Exceptions:
-
BrokenBarrier_Exception |
thrown when any of the thread that has left the Barrier as a result of an error or exception. |
Interrupted_Exception |
thrown when the calling thread is interupt()ed. A thread may be interrupted at any time, prematurely ending any wait. |
- See also:
-
Waitable::wait()
- Postcondition:
-
All threads have successfully arrived at the Barrier if no exception is thrown
Reimplemented from Waitable. |
The documentation for this class was generated from the following file:
Generated on Tue Aug 27 07:43:10 2002 for ZThread by
1.2.17