00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBarrier_h_
00018 #define __itkBarrier_h_
00019
00020 #include "itkLightObject.h"
00021 #include "itkConditionVariable.h"
00022 #include "itkMutexLock.h"
00023
00024 #ifdef ITK_USE_FETCHOP_BARRIERS
00025 extern "C" {
00026 #include <sys/pmo.h>
00027 #include <fetchop.h>
00028 }
00029 #endif
00030
00031 #ifdef ITK_USE_SPROC
00032 extern "C" {
00033 #include <ulocks.h>
00034 }
00035 #endif
00036
00037 namespace itk {
00038
00062 class ITKCommon_EXPORT Barrier : public LightObject
00063 {
00064 public:
00066 typedef Barrier Self;
00067 typedef LightObject Superclass;
00068 typedef SmartPointer<Self> Pointer;
00069 typedef SmartPointer<const Self> ConstPointer;
00070
00072 itkNewMacro(Self);
00073
00075 itkTypeMacro(Barrier, Object);
00076
00080 void Initialize(unsigned int);
00081
00085 void Wait();
00086
00087 private:
00088 Barrier();
00089 ~Barrier();
00090
00091 #if defined ITK_USE_FETCHOP_BARRIERS
00092 static bool m_ReservoirInitialized;
00093 static atomic_reservoir_t m_Reservoir;
00094 static int m_MaxBarriers;
00095 atomic_var_t *m_Pvar;
00096
00097 char pad1[128];
00098 volatile int m_FetchopFlag;
00099 char pad2[128];
00100
00101 #elif defined ITK_USE_SPROC
00102 barrier_t *m_Barrier;
00103
00104 #else
00105 ConditionVariable::Pointer m_ConditionVariable;
00106 unsigned int m_NumberArrived;
00107 SimpleMutexLock m_Mutex;
00108
00109 #endif
00110
00111 unsigned int m_NumberExpected;
00112 };
00113
00114 }
00115
00116 #endif