vpr::BarrierSGI Class Reference

Barrier wrapper for SGI. More...

#include <vpr/Sync/Barrier.h>

Collaboration diagram for vpr::BarrierSGI:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BarrierSGI (int count)
 Initializes the barrier to synchronize count threads.
 ~BarrierSGI ()
int wait (int numProcs)
 Blocks the caller until all numProcs threads have called wait() and then allows all the caller threads to continue in parallel.
int wait ()
void addProcess ()
 Tells the barrier to increase the count of the number of threads to syncronize.
void removeProcess ()
 Tells the barrier to decrease the count of the number of threads to syncronize.
void setProcesses (int procs)

Protected Member Functions

void operator= (const BarrierSGI &)
 BarrierSGI (const BarrierSGI &)

Protected Attributes

Mutex mutex
int syncCount
barrier_t * theBarrier

Static Protected Attributes

static MemPoolSGIbarrierPool
static int * attachedCounter

Detailed Description

Barrier wrapper for SGI.

A barrier is a primitive that allows several processes to wait at a sync point. This is typedef'd to vpr::Barrier.

Date:
January 30, 1997

Definition at line 63 of file BarrierSGI.h.


Constructor & Destructor Documentation

vpr::BarrierSGI::BarrierSGI ( int  count  )  [inline]

Initializes the barrier to synchronize count threads.

Definition at line 69 of file BarrierSGI.h.

References vpr::MemPoolSGI::allocate(), attachedCounter, barrierPool, vpr::MemPoolSGI::getArena(), and theBarrier.

00069                          : syncCount(count)
00070    {
00071       if (barrierPool == NULL)
00072       {
00073          barrierPool = new MemPoolSGI(65536, 32,
00074                                       "/var/tmp/memBarrierPoolSGIXXXXXX");
00075          attachedCounter = static_cast<int*>(barrierPool->allocate(sizeof(int)));
00076          *attachedCounter = 0;
00077       }
00078       *attachedCounter = *attachedCounter + 1;      // Track how many mutexes are allocated
00079       //vprDEBUG << "BarrierSGI::BarrierSGI: attachedCounter: " << *attachedCounter << std::endl << vprDEBUG_FLUSH;
00080 
00081       // ----- Allocate the mutex ----- //
00082       theBarrier = new_barrier(barrierPool->getArena());
00083    }

vpr::BarrierSGI::~BarrierSGI (  )  [inline]

Definition at line 85 of file BarrierSGI.h.

References attachedCounter, barrierPool, vpr::MemPoolSGI::deallocate(), and theBarrier.

00086    {
00087       // ---- Delete the barrier --- //
00088       free_barrier(theBarrier);
00089 
00090       // ---- Deal with the pool --- //
00091       *attachedCounter = *attachedCounter - 1;     // Track how many mutexes are allocated
00092 
00093       //vprDEBUG << "BarrierSGI::~BarrierSGI: attachedCounter: " << *attachedCounter << std::endl << vprDEBUG_FLUSH;
00094 
00095       if (*attachedCounter == 0)
00096       {
00097          barrierPool->deallocate(attachedCounter);
00098          attachedCounter = NULL;
00099          delete barrierPool;
00100          barrierPool = NULL;
00101       }
00102    }

vpr::BarrierSGI::BarrierSGI ( const BarrierSGI  )  [inline, protected]

Definition at line 153 of file BarrierSGI.h.

00153 {;}


Member Function Documentation

int vpr::BarrierSGI::wait ( int  numProcs  )  [inline]

Blocks the caller until all numProcs threads have called wait() and then allows all the caller threads to continue in parallel.

Definition at line 108 of file BarrierSGI.h.

00109    {
00110       return -1;
00111    }

int vpr::BarrierSGI::wait (  )  [inline]

Definition at line 113 of file BarrierSGI.h.

References syncCount, and theBarrier.

00114    {
00115       barrier(theBarrier, syncCount);
00116       //init_barrier(theBarrier);       // -- How do I reset the barrier -- //
00117       return 0;
00118    }

void vpr::BarrierSGI::addProcess (  )  [inline]

Tells the barrier to increase the count of the number of threads to syncronize.

Definition at line 124 of file BarrierSGI.h.

References mutex, and syncCount.

00125    {
00126       Guard<Mutex> guard(mutex);
00127       syncCount++;
00128    }

void vpr::BarrierSGI::removeProcess (  )  [inline]

Tells the barrier to decrease the count of the number of threads to syncronize.

Definition at line 134 of file BarrierSGI.h.

References mutex, and syncCount.

00135    {
00136       Guard<Mutex> guard(mutex);
00137       syncCount--;
00138    }

void vpr::BarrierSGI::setProcesses ( int  procs  )  [inline]

Definition at line 140 of file BarrierSGI.h.

References mutex, and syncCount.

00141    {
00142       Guard<Mutex> guard(mutex);
00143       syncCount = procs;
00144    }

void vpr::BarrierSGI::operator= ( const BarrierSGI  )  [inline, protected]

Definition at line 152 of file BarrierSGI.h.

00152 {;}


Member Data Documentation

Mutex vpr::BarrierSGI::mutex [protected]

Definition at line 147 of file BarrierSGI.h.

Referenced by addProcess(), removeProcess(), and setProcesses().

int vpr::BarrierSGI::syncCount [protected]

Definition at line 148 of file BarrierSGI.h.

Referenced by addProcess(), removeProcess(), setProcesses(), and wait().

barrier_t* vpr::BarrierSGI::theBarrier [protected]

Definition at line 149 of file BarrierSGI.h.

Referenced by BarrierSGI(), wait(), and ~BarrierSGI().

vpr::MemPoolSGI * vpr::BarrierSGI::barrierPool [static, protected]

Definition at line 155 of file BarrierSGI.h.

Referenced by BarrierSGI(), and ~BarrierSGI().

int * vpr::BarrierSGI::attachedCounter [static, protected]

Definition at line 156 of file BarrierSGI.h.

Referenced by BarrierSGI(), and ~BarrierSGI().


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:55:45 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1