VTK
vtkMutexLock.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMutexLock.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
27#ifndef vtkMutexLock_h
28#define vtkMutexLock_h
29
30
31#include "vtkCommonCoreModule.h" // For export macro
32#include "vtkObject.h"
33
34#ifdef VTK_USE_SPROC
35#include <abi_mutex.h> // Needed for SPROC implementation of mutex
36typedef abilock_t vtkMutexType;
37#endif
38
39#if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
40#include <pthread.h> // Needed for PTHREAD implementation of mutex
41typedef pthread_mutex_t vtkMutexType;
42#endif
43
44#ifdef VTK_USE_WIN32_THREADS
45typedef vtkWindowsHANDLE vtkMutexType;
46#endif
47
48#ifndef VTK_USE_SPROC
49#ifndef VTK_USE_PTHREADS
50#ifndef VTK_USE_WIN32_THREADS
51typedef int vtkMutexType;
52#endif
53#endif
54#endif
55
56// Mutex lock that is not a vtkObject.
57class VTKCOMMONCORE_EXPORT vtkSimpleMutexLock
58{
59public:
60 // left public purposely
63
65
66 void Delete() {delete this;}
67
71 void Lock( void );
72
76 void Unlock( void );
77
78protected:
81
82private:
83 vtkSimpleMutexLock(const vtkSimpleMutexLock& other) VTK_DELETE_FUNCTION;
84 vtkSimpleMutexLock& operator=(const vtkSimpleMutexLock& rhs) VTK_DELETE_FUNCTION;
85};
86
87class VTKCOMMONCORE_EXPORT vtkMutexLock : public vtkObject
88{
89public:
90 static vtkMutexLock *New();
91
92 vtkTypeMacro(vtkMutexLock,vtkObject);
93 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
94
98 void Lock( void );
99
103 void Unlock( void );
104
105protected:
106
107 friend class vtkConditionVariable; // needs to get at SimpleMutexLock.
108
111private:
112 vtkMutexLock(const vtkMutexLock&) VTK_DELETE_FUNCTION;
113 void operator=(const vtkMutexLock&) VTK_DELETE_FUNCTION;
114};
115
116
117inline void vtkMutexLock::Lock( void )
118{
119 this->SimpleMutexLock.Lock();
120}
121
122inline void vtkMutexLock::Unlock( void )
123{
124 this->SimpleMutexLock.Unlock();
125}
126
127#endif
mutual exclusion locking class
a simple class to control print indentation
Definition: vtkIndent.h:40
mutual exclusion locking class
Definition: vtkMutexLock.h:88
void Lock(void)
Lock the vtkMutexLock.
Definition: vtkMutexLock.h:117
vtkSimpleMutexLock SimpleMutexLock
Definition: vtkMutexLock.h:109
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Unlock(void)
Unlock the vtkMutexLock.
Definition: vtkMutexLock.h:122
static vtkMutexLock * New()
abstract base class for most VTK objects
Definition: vtkObject.h:60
void Lock(void)
Lock the vtkMutexLock.
void Unlock(void)
Unlock the vtkMutexLock.
virtual ~vtkSimpleMutexLock()
static vtkSimpleMutexLock * New()
vtkMutexType MutexLock
Definition: vtkMutexLock.h:80
int vtkMutexType
Definition: vtkMutexLock.h:51