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: 2007-01-26 14:28:44 $
00007   Version:   $Revision: 1.11 $
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 
00107                                            // m_NumberOfWaiters
00108 
00109   HANDLE m_Semaphore;                      // Semaphore to queue threads 
00110   HANDLE m_WaitersAreDone;                 // Auto-reset event used by the
00111                                            // broadcast/signal thread to
00112                                            // wait for all the waiting
00113                                            // threads to wake up and
00114                                            // release the semaphore
00115 
00116   size_t m_WasBroadcast;                   // Keeps track of whether we
00117                                            // were broadcasting or signaling
00118 #endif
00119 #endif
00120 };
00121 
00122 } // end namespace itk
00123 
00124 #endif
00125 

Generated at Mon Jul 12 2010 18:06:03 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000