VTK  9.1.0
vtkSimpleCriticalSection.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=========================================================================*/
36#ifndef vtkSimpleCriticalSection_h
37#define vtkSimpleCriticalSection_h
38
39#include "vtkCommonCoreModule.h" // For export macro
40#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
41#include "vtkSystemIncludes.h"
42#include "vtkThreads.h" // for VTK_USE_PTHREADS and VTK_USE_WIN32_THREADS
43
44#if defined(VTK_USE_PTHREADS)
45#include <pthread.h> // Needed for pthreads implementation of mutex
46typedef pthread_mutex_t vtkCritSecType;
47#endif
48
49#ifdef VTK_USE_WIN32_THREADS
50#include "vtkWindows.h" // Needed for win32 implementation of mutex
51typedef CRITICAL_SECTION vtkCritSecType;
52#endif
53
54#ifndef VTK_USE_PTHREADS
55#ifndef VTK_USE_WIN32_THREADS
56typedef int vtkCritSecType;
57#endif
58#endif
59
60// Critical Section object that is not a vtkObject.
62 "Use std::mutex instead.") VTKCOMMONCORE_EXPORT vtkSimpleCriticalSection
63{
64public:
65 // Default cstor
66 vtkSimpleCriticalSection() { this->Init(); }
67 // Construct object locked if isLocked is different from 0
69 {
70 this->Init();
71 if (isLocked)
72 {
73 this->Lock();
74 }
75 }
76 // Destructor
78
79 void Init();
80
84 void Lock();
85
89 void Unlock();
90
91protected:
93
94private:
96 vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs) = delete;
97};
98
99#endif
100// VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h
Critical section locking class.
void Unlock()
Unlock the vtkCriticalSection.
void Lock()
Lock the vtkCriticalSection.
virtual ~vtkSimpleCriticalSection()
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkCritSecType