VTK
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
64  {
65  this->Init();
66  }
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
77  virtual ~vtkSimpleCriticalSection();
78 
79  void Init();
80 
84  void Lock();
85 
89  void Unlock();
90 
91 protected:
93 
94 private:
96  vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs) = delete;
97 };
98 
99 #endif
100 // VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h
int vtkCritSecType
Critical section locking class.