Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkConditionVariable.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkConditionVariable.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:04 $ 00007 Version: $Revision: 1.7 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef _itkConditionVariable_h_ 00018 #define _itkConditionVariable_h_ 00019 00020 #include "itkConfigure.h" 00021 00022 // This implementation uses a routine called SignalObjectAndWait() 00023 // which is only defined on WinNT 4.0 or greater systems. We need to 00024 // define this symbol in order to get the prototype for the 00025 // routine. This needs to be done before we load any system headers. 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; // number of waiting threads 00104 #ifdef WIN32 00105 CRITICAL_SECTION m_NumberOfWaitersLock; // Serialize access to m_NumberOfWaiters 00106 00107 HANDLE m_Semaphore; // Semaphore to queue threads 00108 HANDLE m_WaitersAreDone; // Auto-reset event used by the 00109 // broadcast/signal thread to 00110 // wait for all the waiting 00111 // threads to wake up and 00112 // release the semaphore 00113 00114 size_t m_WasBroadcast; // Keeps track of whether we 00115 // were broadcasting or signaling 00116 #endif 00117 #endif 00118 }; 00119 00120 }//end of itk namespace 00121 00122 #endif

Generated at Sun Apr 1 02:26:01 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000