Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkMutexLock.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkMutexLock.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00027 #ifndef __vtkMutexVariable_h 00028 #define __vtkMutexVariable_h 00029 00030 00031 #include "vtkObject.h" 00032 00033 //BTX 00034 00035 #ifdef VTK_USE_SPROC 00036 #include <abi_mutex.h> // Needed for SPROC implementation of mutex 00037 typedef abilock_t vtkMutexType; 00038 #endif 00039 00040 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS) 00041 #include <pthread.h> // Needed for PTHREAD implementation of mutex 00042 typedef pthread_mutex_t vtkMutexType; 00043 #endif 00044 00045 #ifdef VTK_USE_WIN32_THREADS 00046 #include <winbase.h> // Needed for WIN32 implementation of mutex 00047 typedef HANDLE vtkMutexType; 00048 #endif 00049 00050 #ifndef VTK_USE_SPROC 00051 #ifndef VTK_USE_PTHREADS 00052 #ifndef VTK_USE_WIN32_THREADS 00053 typedef int vtkMutexType; 00054 #endif 00055 #endif 00056 #endif 00057 00058 // Mutex lock that is not a vtkObject. 00059 class VTK_COMMON_EXPORT vtkSimpleMutexLock 00060 { 00061 public: 00062 // left public purposely 00063 vtkSimpleMutexLock(); 00064 virtual ~vtkSimpleMutexLock(); 00065 00066 static vtkSimpleMutexLock *New(); 00067 00068 virtual const char *GetClassName() {return "vtkSimpleMutexLock";}; 00069 virtual int IsA(const char *name); 00070 static vtkSimpleMutexLock *SafeDownCast(vtkSimpleMutexLock *o); 00071 00072 void Delete() {delete this;} 00073 00075 void Lock( void ); 00076 00078 void Unlock( void ); 00079 00080 protected: 00081 vtkMutexType MutexLock; 00082 }; 00083 00084 //ETX 00085 00086 class VTK_COMMON_EXPORT vtkMutexLock : public vtkObject 00087 { 00088 public: 00089 static vtkMutexLock *New(); 00090 00091 vtkTypeRevisionMacro(vtkMutexLock,vtkObject); 00092 void PrintSelf(ostream& os, vtkIndent indent); 00093 00095 void Lock( void ); 00096 00098 void Unlock( void ); 00099 00100 protected: 00101 vtkSimpleMutexLock SimpleMutexLock; 00102 vtkMutexLock() {}; 00103 private: 00104 vtkMutexLock(const vtkMutexLock&); // Not implemented. 00105 void operator=(const vtkMutexLock&); // Not implemented. 00106 }; 00107 00108 00109 inline void vtkMutexLock::Lock( void ) 00110 { 00111 this->SimpleMutexLock.Lock(); 00112 } 00113 00114 inline void vtkMutexLock::Unlock( void ) 00115 { 00116 this->SimpleMutexLock.Unlock(); 00117 } 00118 00119 #endif