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