VTK  9.2.5
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#include "vtkCommonCoreModule.h" // For export macro
31#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
32#include "vtkObject.h"
33#include "vtkThreads.h" // for VTK_USE_PTHREADS and VTK_USE_WIN32_THREADS
34
35#if defined(VTK_USE_PTHREADS)
36#include <pthread.h> // Needed for PTHREAD implementation of mutex
37typedef pthread_mutex_t vtkMutexType;
38#endif
39
40#ifdef VTK_USE_WIN32_THREADS
41typedef vtkWindowsHANDLE vtkMutexType;
42#endif
43
44#ifndef VTK_USE_PTHREADS
45#ifndef VTK_USE_WIN32_THREADS
46typedef int vtkMutexType;
47#endif
48#endif
49
50// Mutex lock that is not a vtkObject.
51
52class VTK_DEPRECATED_IN_9_1_0("Use std::mutex instead.") VTKCOMMONCORE_EXPORT vtkSimpleMutexLock
53{
54public:
55 // left public purposely
58
60
61 void Delete() { delete this; }
62
66 void Lock(void);
67
71 void Unlock(void);
72
73protected:
76
77private:
78 vtkSimpleMutexLock(const vtkSimpleMutexLock& other) = delete;
79 vtkSimpleMutexLock& operator=(const vtkSimpleMutexLock& rhs) = delete;
80};
81
82class VTK_DEPRECATED_IN_9_1_0("Use std::mutex instead.") VTKCOMMONCORE_EXPORT vtkMutexLock
83 : public vtkObject
84{
85public:
86 static vtkMutexLock* New();
87
88 vtkTypeMacro(vtkMutexLock, vtkObject);
89 void PrintSelf(ostream& os, vtkIndent indent) override;
90
94 void Lock(void);
95
99 void Unlock(void);
100
101protected:
102 friend class vtkConditionVariable; // needs to get at SimpleMutexLock.
103
105 vtkMutexLock() = default;
106
107private:
108 vtkMutexLock(const vtkMutexLock&) = delete;
109 void operator=(const vtkMutexLock&) = delete;
110};
111
112inline void vtkMutexLock::Lock(void)
113{
114 this->SimpleMutexLock.Lock();
115}
116
117inline void vtkMutexLock::Unlock(void)
118{
119 this->SimpleMutexLock.Unlock();
120}
121
122#endif
123
124// VTK-HeaderTest-Exclude: vtkMutexLock.h
mutual exclusion locking class
a simple class to control print indentation
Definition: vtkIndent.h:40
mutual exclusion locking class
Definition: vtkMutexLock.h:84
void Lock(void)
Lock the vtkMutexLock.
Definition: vtkMutexLock.h:112
vtkSimpleMutexLock SimpleMutexLock
Definition: vtkMutexLock.h:104
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:117
vtkMutexLock()=default
static vtkMutexLock * New()
abstract base class for most VTK objects
Definition: vtkObject.h:63
void Lock(void)
Lock the vtkMutexLock.
void Unlock(void)
Unlock the vtkMutexLock.
virtual ~vtkSimpleMutexLock()
static vtkSimpleMutexLock * New()
vtkMutexType MutexLock
Definition: vtkMutexLock.h:75
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkMutexType
Definition: vtkMutexLock.h:46