vtkMutexLock.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00027 #ifndef __vtkMutexVariable_h
00028 #define __vtkMutexVariable_h
00029
00030
00031 #include "vtkObject.h"
00032
00033
00034
00035 #ifdef VTK_USE_SPROC
00036 #include <abi_mutex.h>
00037 typedef abilock_t vtkMutexType;
00038 #endif
00039
00040 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00041 #include <pthread.h>
00042 typedef pthread_mutex_t vtkMutexType;
00043 #endif
00044
00045 #ifdef VTK_USE_WIN32_THREADS
00046 #include <winbase.h>
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
00059 class VTK_COMMON_EXPORT vtkSimpleMutexLock
00060 {
00061 public:
00062
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
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&);
00105 void operator=(const vtkMutexLock&);
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