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: 2004/12/11 17:31:47 $
00007   Version:   $Revision: 1.8 $
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 #undef _WIN32_WINNT
00028 #define _WIN32_WINNT 0x0400
00029 #endif
00030 
00031 #include "itkMutexLock.h"
00032 #include "itkLightObject.h"
00033 
00034 
00035 namespace itk {
00036 
00067 class ITKCommon_EXPORT ConditionVariable : public LightObject
00068 {
00069 public:
00071   typedef ConditionVariable Self;
00072   typedef LightObject Superclass;
00073   typedef SmartPointer<Self> Pointer;
00074   typedef SmartPointer<const Self> ConstPointer;
00075   
00077   itkNewMacro(Self);
00078   
00080   itkTypeMacro(ConditionVariable, LightObject);
00081 
00085   void Wait(SimpleMutexLock * mutex);
00086 
00088   void Signal();
00089 
00091   void Broadcast();
00092 
00093 protected:
00094   ConditionVariable();
00095   ~ConditionVariable();
00096 
00097 private:
00098   ConditionVariable(const Self & other);
00099   const Self & operator=( const Self & );
00100 #ifdef ITK_USE_PTHREADS
00101   pthread_cond_t m_ConditionVariable;
00102   MutexType m_Mutex;
00103 #else
00104   int m_NumberOfWaiters;                   // number of waiting threads
00105 #ifdef WIN32
00106   CRITICAL_SECTION m_NumberOfWaitersLock;  // Serialize access to m_NumberOfWaiters
00107 
00108   HANDLE m_Semaphore;                      // Semaphore to queue threads 
00109   HANDLE m_WaitersAreDone;                 // Auto-reset event used by the
00110                                            // broadcast/signal thread to
00111                                            // wait for all the waiting
00112                                            // threads to wake up and
00113                                            // release the semaphore
00114 
00115   size_t m_WasBroadcast;                   // Keeps track of whether we
00116                                            // were broadcasting or signaling
00117 #endif
00118 #endif
00119 };
00120 
00121 }//end of itk namespace
00122 
00123 #endif

Generated at Wed May 24 22:57:50 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000