00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00023 #ifndef __vtkMutexVariable_h
00024 #define __vtkMutexVariable_h
00025
00026
00027 #include "vtkObject.h"
00028
00029
00030
00031 #ifdef VTK_USE_SPROC
00032 #include <abi_mutex.h>
00033 typedef abilock_t vtkMutexType;
00034 #endif
00035
00036 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00037 #include <pthread.h>
00038 typedef pthread_mutex_t vtkMutexType;
00039 #endif
00040
00041 #ifdef VTK_USE_WIN32_THREADS
00042 typedef vtkWindowsHANDLE vtkMutexType;
00043 #endif
00044
00045 #ifndef VTK_USE_SPROC
00046 #ifndef VTK_USE_PTHREADS
00047 #ifndef VTK_USE_WIN32_THREADS
00048 typedef int vtkMutexType;
00049 #endif
00050 #endif
00051 #endif
00052
00053
00054 class VTK_COMMON_EXPORT vtkSimpleMutexLock
00055 {
00056 public:
00057
00058 vtkSimpleMutexLock();
00059 virtual ~vtkSimpleMutexLock();
00060
00061 static vtkSimpleMutexLock *New();
00062
00063 void Delete() {delete this;}
00064
00066 void Lock( void );
00067
00069 void Unlock( void );
00070
00071 protected:
00072 vtkMutexType MutexLock;
00073 };
00074
00075
00076
00077 class VTK_COMMON_EXPORT vtkMutexLock : public vtkObject
00078 {
00079 public:
00080 static vtkMutexLock *New();
00081
00082 vtkTypeRevisionMacro(vtkMutexLock,vtkObject);
00083 void PrintSelf(ostream& os, vtkIndent indent);
00084
00086 void Lock( void );
00087
00089 void Unlock( void );
00090
00091 protected:
00092 vtkSimpleMutexLock SimpleMutexLock;
00093 vtkMutexLock() {};
00094 private:
00095 vtkMutexLock(const vtkMutexLock&);
00096 void operator=(const vtkMutexLock&);
00097 };
00098
00099
00100 inline void vtkMutexLock::Lock( void )
00101 {
00102 this->SimpleMutexLock.Lock();
00103 }
00104
00105 inline void vtkMutexLock::Unlock( void )
00106 {
00107 this->SimpleMutexLock.Unlock();
00108 }
00109
00110 #endif