VTK  9.2.6
vtkCriticalSection.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCriticalSection.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=========================================================================*/
35
36#ifndef vtkCriticalSection_h
37#define vtkCriticalSection_h
38
39#include "vtkCommonCoreModule.h" // For export macro
40#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
41#include "vtkObject.h"
42#include <mutex> // for std::mutex
43
44// Remove with VTK_DEPRECATED_IN_9_2_0 because it was not actually deprecated
45// in 9.1.0.
46VTK_DEPRECATED_IN_9_1_0("Use std::mutex instead")
47class VTKCOMMONCORE_EXPORT vtkCriticalSection : public vtkObject
48{
49public:
51
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
58 void Lock();
59
63 void Unlock();
64
65protected:
66 std::mutex mtx;
67 vtkCriticalSection() = default;
68 ~vtkCriticalSection() override = default;
69
70private:
72 void operator=(const vtkCriticalSection&) = delete;
73};
74
76{
77 this->mtx.lock();
78}
79
81{
82 this->mtx.unlock();
83}
84
85#endif
void Unlock()
Unlock the vtkCriticalSection.
static vtkCriticalSection * New()
vtkCriticalSection()=default
void Lock()
Lock the vtkCriticalSection.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkCriticalSection() override=default
a simple class to control print indentation
Definition vtkIndent.h:34
#define VTK_DEPRECATED_IN_9_1_0(reason)