vtkMutexLock.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00037 #ifndef __vtkMutexVariable_h
00038 #define __vtkMutexVariable_h
00039
00040
00041 #include "vtkObject.h"
00042
00043
00044
00045 #ifdef VTK_USE_SPROC
00046 #include <abi_mutex.h>
00047 typedef abilock_t vtkMutexType;
00048 #endif
00049
00050 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00051 #include <pthread.h>
00052 typedef pthread_mutex_t vtkMutexType;
00053 #endif
00054
00055 #ifdef VTK_USE_WIN32_THREADS
00056 #include <winbase.h>
00057 typedef HANDLE vtkMutexType;
00058 #endif
00059
00060 #ifndef VTK_USE_SPROC
00061 #ifndef VTK_USE_PTHREADS
00062 #ifndef VTK_USE_WIN32_THREADS
00063 typedef int vtkMutexType;
00064 #endif
00065 #endif
00066 #endif
00067
00068
00069 class VTK_COMMON_EXPORT vtkSimpleMutexLock
00070 {
00071 public:
00072
00073 vtkSimpleMutexLock();
00074 virtual ~vtkSimpleMutexLock();
00075
00076 static vtkSimpleMutexLock *New();
00077
00078 virtual const char *GetClassName() {return "vtkSimpleMutexLock";};
00079 virtual int IsA(const char *name);
00080 static vtkSimpleMutexLock *SafeDownCast(vtkSimpleMutexLock *o);
00081
00082 void Delete() {delete this;}
00083
00085 void Lock( void );
00086
00088 void Unlock( void );
00089
00090 protected:
00091 vtkMutexType MutexLock;
00092 };
00093
00094
00095
00096 class VTK_COMMON_EXPORT vtkMutexLock : public vtkObject
00097 {
00098 public:
00099 static vtkMutexLock *New();
00100
00101 vtkTypeRevisionMacro(vtkMutexLock,vtkObject);
00102 void PrintSelf(ostream& os, vtkIndent indent);
00103
00105 void Lock( void );
00106
00108 void Unlock( void );
00109
00110 protected:
00111 vtkSimpleMutexLock SimpleMutexLock;
00112 vtkMutexLock() {};
00113 private:
00114 vtkMutexLock(const vtkMutexLock&);
00115 void operator=(const vtkMutexLock&);
00116 };
00117
00118
00119 inline void vtkMutexLock::Lock( void )
00120 {
00121 this->SimpleMutexLock.Lock();
00122 }
00123
00124 inline void vtkMutexLock::Unlock( void )
00125 {
00126 this->SimpleMutexLock.Unlock();
00127 }
00128
00129 #endif