Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWBarrier

Module:  Threads   Package:  Synchronization


Base Class

Local Index

Members

Header File

#include <rw/sync/RWBarrier.h>

Description

Use an RWBarrier object to synchronize a number of concurrent threads at a specific point in their processing. Each thread indicates that it has reached the "barrier" by calling the wait() member function. Each thread is blocked by the call to wait() until the number of threads specified in the RWBarrier constructor have all called wait(). When the last thread calls wait(), all threads waiting at the barrier are unblocked, making them eligible for execution.

Initializing an RWBarrier with a zero count is not legal; an assertion will be triggered in debug mode. Using an RWBarrier with a count different than the number of threads able to perform a wait() on that RWBarrier is outside the intended use of the class. There is no diagnostic available to detect this condition.

An RWBarrier's count may be changed after initialization by using the setCount(int) function. No threads must be blocked in wait() when this function is called. In debug mode, if there are threads blocked in wait(), an assertion will be triggered; in release mode, an exception will be thrown.

When an RWBarrier is destroyed, no threads should be blocked in the wait() function. When the module is built in debug mode, an assertion will be raised if there are threads waiting when the RWBarrier is destructed.

Example

Public Constructor

RWBarrier(int count=1);

Public Destructor

~RWBarrier();

Public Member Functions

void
setCount(int count);
void
wait();

Private Constructor

RWBarrier(const RWBarrier& second);

Private Member Operator

RWBarrier&
operator=(const RWBarrier& second);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.