dox/Common/vtkMutexLock.h
Go to the documentation of this file.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
#include <winbase.h>
00043
typedef HANDLE
vtkMutexType;
00044
#endif
00045
00046
#ifndef VTK_USE_SPROC
00047
#ifndef VTK_USE_PTHREADS
00048
#ifndef VTK_USE_WIN32_THREADS
00049 typedef int vtkMutexType;
00050
#endif
00051
#endif
00052
#endif
00053
00054
00055 class VTK_COMMON_EXPORT vtkSimpleMutexLock
00056 {
00057
public:
00058
00059 vtkSimpleMutexLock();
00060
virtual ~vtkSimpleMutexLock();
00061
00062
static vtkSimpleMutexLock *New();
00063
00064 virtual const char *GetClassName() {
return "vtkSimpleMutexLock";};
00065
virtual int IsA(
const char *name);
00066
static vtkSimpleMutexLock *SafeDownCast(vtkSimpleMutexLock *o);
00067
00068 void Delete() {
delete this;}
00069
00071
void Lock(
void );
00072
00074
void Unlock(
void );
00075
00076
protected:
00077 vtkMutexType MutexLock;
00078 };
00079
00080
00081
00082 class VTK_COMMON_EXPORT vtkMutexLock :
public vtkObject
00083 {
00084
public:
00085
static vtkMutexLock *
New();
00086
00087 vtkTypeRevisionMacro(vtkMutexLock,
vtkObject);
00088
void PrintSelf(ostream& os,
vtkIndent indent);
00089
00091
void Lock(
void );
00092
00094
void Unlock(
void );
00095
00096
protected:
00097 vtkSimpleMutexLock SimpleMutexLock;
00098 vtkMutexLock() {};
00099
private:
00100 vtkMutexLock(
const vtkMutexLock&);
00101
void operator=(
const vtkMutexLock&);
00102 };
00103
00104
00105 inline void vtkMutexLock::Lock(
void )
00106 {
00107 this->
SimpleMutexLock.
Lock();
00108 }
00109
00110 inline void vtkMutexLock::Unlock(
void )
00111 {
00112 this->
SimpleMutexLock.
Unlock();
00113 }
00114
00115
#endif