1/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
16// Barrier - C++ barrier class
20#ifndef _OPENTHREADS_BARRIER_
21#define _OPENTHREADS_BARRIER_
23#include <OpenThreads/Exports>
25namespace OpenThreads {
30 * @brief This class provides an object-oriented thread barrier interface
32 * @warning It is unwise to use the construct "Barrier barrier" in the
33 * global namespace on sgi's. The object "barrier"
34 * will confilict with the c-library sproc function "barrier" and
35 * unpredictable results may occur. You have been warned.
37class OPENTHREAD_EXPORT_DIRECTIVE Barrier {
44 Barrier(int numThreads=0);
52 * Reset the barrier to it's original state.
57 * Block until numThreads threads have entered the barrier.
59 virtual void block(unsigned int numThreads=0);
62 * Release the barrier, now.
64 virtual void release();
67 * Return the number of threads currently blocked in the barrier,
70 virtual int numThreadsCurrentlyBlocked();
78 * Private copy constructor, to prevent tampering.
80 Barrier(const Barrier &/*b*/) {};
83 * Private copy assignment, to prevent tampering.
85 Barrier &operator=(const Barrier &/*b*/) {return *(this);};
88 * Implementation-specific private data.
99#endif // !_OPENTHREADS_BARRIER_