00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkConditionVariable_h_
00018 #define _itkConditionVariable_h_
00019
00020 #include "itkConfigure.h"
00021
00022
00023
00024
00025
00026 #ifdef ITK_USE_WIN32_THREADS
00027 #define _WIN32_WINNT 0x0400
00028 #endif
00029
00030 #include "itkMutexLock.h"
00031 #include "itkLightObject.h"
00032
00033
00034 namespace itk {
00035
00066 class ITKCommon_EXPORT ConditionVariable : public LightObject
00067 {
00068 public:
00070 typedef ConditionVariable Self;
00071 typedef LightObject Superclass;
00072 typedef SmartPointer<Self> Pointer;
00073 typedef SmartPointer<const Self> ConstPointer;
00074
00076 itkNewMacro(Self);
00077
00079 itkTypeMacro(ConditionVariable, LightObject);
00080
00084 void Wait(SimpleMutexLock * mutex);
00085
00087 void Signal();
00088
00090 void Broadcast();
00091
00092 protected:
00093 ConditionVariable();
00094 ~ConditionVariable();
00095
00096 private:
00097 ConditionVariable(const Self & other);
00098 const Self & operator=( const Self & );
00099 #ifdef ITK_USE_PTHREADS
00100 pthread_cond_t m_ConditionVariable;
00101 MutexType m_Mutex;
00102 #else
00103 int m_NumberOfWaiters;
00104 #ifdef WIN32
00105 CRITICAL_SECTION m_NumberOfWaitersLock;
00106
00107 HANDLE m_Semaphore;
00108 HANDLE m_WaitersAreDone;
00109
00110
00111
00112
00113
00114 size_t m_WasBroadcast;
00115
00116 #endif
00117 #endif
00118 };
00119
00120 }
00121
00122 #endif