vtkCriticalSection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00048 #ifndef __vtkCriticalSection_h
00049 #define __vtkCriticalSection_h
00050
00051 #include "vtkObject.h"
00052
00053
00054
00055 #ifdef VTK_USE_SPROC
00056 #include <abi_mutex.h>
00057 typedef abilock_t vtkCritSecType;
00058 #endif
00059
00060 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00061 #include <pthread.h>
00062 typedef pthread_mutex_t vtkCritSecType;
00063 #endif
00064
00065 #ifdef VTK_USE_WIN32_THREADS
00066 #include <winbase.h>
00067 typedef CRITICAL_SECTION vtkCritSecType;
00068 #endif
00069
00070 #ifndef VTK_USE_SPROC
00071 #ifndef VTK_USE_PTHREADS
00072 #ifndef VTK_USE_WIN32_THREADS
00073 typedef int vtkCritSecType;
00074 #endif
00075 #endif
00076 #endif
00077
00078
00079 class VTK_COMMON_EXPORT vtkSimpleCriticalSection
00080 {
00081 public:
00082 vtkSimpleCriticalSection()
00083 {
00084 this->Init();
00085 }
00086
00087 vtkSimpleCriticalSection(int isLocked)
00088 {
00089 this->Init();
00090 if(isLocked)
00091 {
00092 this->Lock();
00093 }
00094 }
00095
00096 void Init();
00097
00098 virtual ~vtkSimpleCriticalSection();
00099
00100 static vtkSimpleCriticalSection *New();
00101
00102
00103
00104 virtual const char *GetClassName() {return "vtkSimpleCriticalSection";};
00105 virtual int IsA(const char *name);
00106 static vtkSimpleCriticalSection *SafeDownCast(vtkSimpleCriticalSection *o);
00107
00108 void Delete() {delete this;}
00109
00111 void Lock( void );
00112
00114 void Unlock( void );
00115
00116 protected:
00117 vtkCritSecType CritSec;
00118 };
00119
00120
00121
00122 class VTK_COMMON_EXPORT vtkCriticalSection : public vtkObject
00123 {
00124 public:
00125 static vtkCriticalSection *New();
00126
00127 vtkTypeRevisionMacro(vtkCriticalSection,vtkObject);
00128 void PrintSelf(ostream& os, vtkIndent indent);
00129
00131 void Lock( void );
00132
00134 void Unlock( void );
00135
00136 protected:
00137 vtkSimpleCriticalSection SimpleCriticalSection;
00138 vtkCriticalSection() {};
00139 private:
00140 vtkCriticalSection(const vtkCriticalSection&);
00141 void operator=(const vtkCriticalSection&);
00142 };
00143
00144
00145 inline void vtkCriticalSection::Lock( void )
00146 {
00147 this->SimpleCriticalSection.Lock();
00148 }
00149
00150 inline void vtkCriticalSection::Unlock( void )
00151 {
00152 this->SimpleCriticalSection.Unlock();
00153 }
00154
00155 #endif