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

itkMutexLock.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkMutexLock.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:17 $ 00007 Version: $Revision: 1.21 $ 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 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkMutexLock_h 00021 #define __itkMutexLock_h 00022 00023 #include "itkObject.h" 00024 #include "itkObjectFactory.h" 00025 00026 #ifdef ITK_USE_SPROC 00027 #include <abi_mutex.h> 00028 #endif 00029 00030 #ifdef ITK_USE_PTHREADS 00031 #include <pthread.h> 00032 #endif 00033 00034 #ifdef ITK_USE_WIN32_THREADS 00035 #include "itkWindows.h" 00036 #endif 00037 00038 namespace itk 00039 { 00040 00041 #ifdef ITK_USE_SPROC 00042 typedef abilock_t MutexType; 00043 #endif 00044 00045 #ifdef ITK_USE_PTHREADS 00046 typedef pthread_mutex_t MutexType; 00047 #endif 00048 00049 #ifdef ITK_USE_WIN32_THREADS 00050 typedef HANDLE MutexType; 00051 #endif 00052 00053 #ifndef ITK_USE_SPROC 00054 #ifndef ITK_USE_PTHREADS 00055 #ifndef ITK_USE_WIN32_THREADS 00056 typedef int MutexType; 00057 #endif 00058 #endif 00059 #endif 00060 00070 class ITKCommon_EXPORT SimpleMutexLock 00071 { 00072 public: 00074 typedef SimpleMutexLock Self; 00075 00077 SimpleMutexLock(); 00078 virtual ~SimpleMutexLock(); 00079 00081 static SimpleMutexLock *New(); 00082 void Delete() {delete this;} 00083 00085 virtual const char *GetNameOfClass() {return "itkSimpleMutexLock";}; 00086 00088 void Lock( void ); 00089 00091 void Unlock( void ); 00092 00094 MutexType& GetMutexLock() 00095 { 00096 return m_MutexLock; 00097 } 00098 const MutexType GetMutexLock() const 00099 { 00100 return m_MutexLock; 00101 } 00102 00103 protected: 00104 MutexType m_MutexLock; 00105 }; 00106 00116 class ITKCommon_EXPORT MutexLock : public Object 00117 { 00118 public: 00120 typedef MutexLock Self; 00121 typedef Object Superclass; 00122 typedef SmartPointer<Self> Pointer; 00123 typedef SmartPointer<const Self> ConstPointer; 00124 00126 itkNewMacro(Self); 00127 00129 itkTypeMacro(MutexLock,Object); 00130 00132 void Lock( void ); 00133 00135 void Unlock( void ); 00136 00137 protected: 00138 MutexLock() {} 00139 ~MutexLock() {} 00140 00141 SimpleMutexLock m_SimpleMutexLock; 00142 void PrintSelf(std::ostream& os, Indent indent) const; 00143 00144 private: 00145 MutexLock(const Self&); //purposely not implemented 00146 void operator=(const Self&); //purposely not implemented 00147 }; 00148 00149 00150 inline void MutexLock::Lock( void ) 00151 { 00152 m_SimpleMutexLock.Lock(); 00153 } 00154 00155 inline void MutexLock::Unlock( void ) 00156 { 00157 m_SimpleMutexLock.Unlock(); 00158 } 00159 00160 00161 }//end itk namespace 00162 #endif

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