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