Portable "barrier" class for synchronizing threads. More...
#include <Inventor/threads/SbThreadBarrier.h>
Public Member Functions | |
SbThreadBarrier (int) | |
virtual | ~SbThreadBarrier (void) |
int | enter () |
This class provides a portable "barrier" for synchronizing threads. It is Implemented using the pthreads API on UNIX/Linux and the Win32 API on Microsoft Windows.
It is not necessary to use this class in order to use multiple threads with Open Inventor. It is provided only as a convenience. (However, note that you should use pthreads on UNIX/Linux and Win32 on Windows to be certain of compatibility with Open Inventor.)
A barrier is one type of synchronization construct for threads. It forces a group of threads to "rendezvous" at a particular point in the code. No thread that enters the barrier may leave the barrier until all the threads have entered the barrier.
Specify the number of threads to be synchronized when you create the barrier object. Note it is critical for every thread in the "group" to enter the barrier. There is no other way to release threads already blocked in the barrier.
SbThread, SbThreadAutoLock, SbThreadAutoReadLock, SbThreadAutoWriteLock, SbThreadMutex, SbThreadRWMutex
SbThreadBarrier::SbThreadBarrier | ( | int | ) |
Creates a thread barrier that will block until N threads have entered the barrier.
virtual SbThreadBarrier::~SbThreadBarrier | ( | void | ) | [virtual] |
Destructor.
int SbThreadBarrier::enter | ( | ) |
Enter the barrier.
Each thread to be synchronized should call this method. Returns 1 if the caller was the last thread to enter the barrier, 0 otherwise.