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 =========================================================================*/
35 #ifndef vtkSimpleCriticalSection_h
36 #define vtkSimpleCriticalSection_h
37 
38 #include "vtkCommonCoreModule.h" // For export macro
39 #include "vtkSystemIncludes.h"
40 
41 //BTX
42 
43 #ifdef VTK_USE_SPROC
44 #include <abi_mutex.h> // Needed for sproc implementation of mutex
45 typedef abilock_t vtkCritSecType;
46 #endif
47 
48 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
49 #include <pthread.h> // Needed for pthreads implementation of mutex
50 typedef pthread_mutex_t vtkCritSecType;
51 #endif
52 
53 #ifdef VTK_USE_WIN32_THREADS
54 # include "vtkWindows.h" // Needed for win32 implementation of mutex
55 typedef CRITICAL_SECTION vtkCritSecType;
56 #endif
57 
58 #ifndef VTK_USE_SPROC
59 #ifndef VTK_USE_PTHREADS
60 #ifndef VTK_USE_WIN32_THREADS
61 typedef int vtkCritSecType;
62 #endif
63 #endif
64 #endif
65 
66 // Critical Section object that is not a vtkObject.
68 {
69 public:
70  // Default cstor
72  {
73  this->Init();
74  }
75  // Construct object locked if isLocked is different from 0
77  {
78  this->Init();
79  if(isLocked)
80  {
81  this->Lock();
82  }
83  }
84  // Destructor
85  virtual ~vtkSimpleCriticalSection();
86 
87  void Init();
88 
90  void Lock();
91 
93  void Unlock();
94 
95 protected:
97 
98 private:
99  vtkSimpleCriticalSection(const vtkSimpleCriticalSection& other); // no copy constructor
100  vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs); // no copy assignment
101 };
102 //ETX
103 
104 #endif
105 // VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h
#define VTKCOMMONCORE_EXPORT
int vtkCritSecType
Critical section locking class.