VTK  9.0.2
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 "vtkSystemIncludes.h"
41 
42 #if defined(VTK_USE_PTHREADS)
43 #include <pthread.h> // Needed for pthreads implementation of mutex
44 typedef pthread_mutex_t vtkCritSecType;
45 #endif
46 
47 #ifdef VTK_USE_WIN32_THREADS
48 #include "vtkWindows.h" // Needed for win32 implementation of mutex
49 typedef CRITICAL_SECTION vtkCritSecType;
50 #endif
51 
52 #ifndef VTK_USE_PTHREADS
53 #ifndef VTK_USE_WIN32_THREADS
54 typedef int vtkCritSecType;
55 #endif
56 #endif
57 
58 // Critical Section object that is not a vtkObject.
59 class VTKCOMMONCORE_EXPORT vtkSimpleCriticalSection
60 {
61 public:
62  // Default cstor
63  vtkSimpleCriticalSection() { this->Init(); }
64  // Construct object locked if isLocked is different from 0
66  {
67  this->Init();
68  if (isLocked)
69  {
70  this->Lock();
71  }
72  }
73  // Destructor
75 
76  void Init();
77 
81  void Lock();
82 
86  void Unlock();
87 
88 protected:
90 
91 private:
93  vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs) = delete;
94 };
95 
96 #endif
97 // VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h
Critical section locking class.
void Unlock()
Unlock the vtkCriticalSection.
void Lock()
Lock the vtkCriticalSection.
virtual ~vtkSimpleCriticalSection()
int vtkCritSecType