VTK  9.3.0
vtkCriticalSection.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
24#ifndef vtkCriticalSection_h
25#define vtkCriticalSection_h
26
27#include "vtkCommonCoreModule.h" // For export macro
28#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
29#include "vtkObject.h"
30#include <mutex> // for std::mutex
31
32VTK_ABI_NAMESPACE_BEGIN
33// Remove with VTK_DEPRECATED_IN_9_2_0 because it was not actually deprecated
34// in 9.1.0.
35class VTK_DEPRECATED_IN_9_1_0("Use std::mutex instead") VTKCOMMONCORE_EXPORT vtkCriticalSection
36 : public vtkObject
37{
38public:
40
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
47 void Lock();
48
52 void Unlock();
53
54protected:
55 std::mutex mtx;
56 vtkCriticalSection() = default;
57 ~vtkCriticalSection() override = default;
58
59private:
61 void operator=(const vtkCriticalSection&) = delete;
62};
63
65{
66 this->mtx.lock();
67}
68
70{
71 this->mtx.unlock();
72}
73
74VTK_ABI_NAMESPACE_END
75#endif
76
77// VTK-HeaderTest-Exclude: vtkCriticalSection.h
Critical section locking class.
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:29
abstract base class for most VTK objects
Definition vtkObject.h:49
#define VTK_DEPRECATED_IN_9_1_0(reason)