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#ifdef VTK_USE_SPROC
43#include <abi_mutex.h> // Needed for sproc implementation of mutex
44typedef abilock_t vtkCritSecType;
45#endif
46
47#if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
48#include <pthread.h> // Needed for pthreads implementation of mutex
49typedef pthread_mutex_t vtkCritSecType;
50#endif
51
52#ifdef VTK_USE_WIN32_THREADS
53# include "vtkWindows.h" // Needed for win32 implementation of mutex
54typedef CRITICAL_SECTION vtkCritSecType;
55#endif
56
57#ifndef VTK_USE_SPROC
58#ifndef VTK_USE_PTHREADS
59#ifndef VTK_USE_WIN32_THREADS
60typedef int vtkCritSecType;
61#endif
62#endif
63#endif
64
65// Critical Section object that is not a vtkObject.
66class VTKCOMMONCORE_EXPORT vtkSimpleCriticalSection
67{
68public:
69 // Default cstor
71 {
72 this->Init();
73 }
74 // Construct object locked if isLocked is different from 0
76 {
77 this->Init();
78 if(isLocked)
79 {
80 this->Lock();
81 }
82 }
83 // Destructor
85
86 void Init();
87
91 void Lock();
92
96 void Unlock();
97
98protected:
100
101private:
102 vtkSimpleCriticalSection(const vtkSimpleCriticalSection& other) VTK_DELETE_FUNCTION;
103 vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs) VTK_DELETE_FUNCTION;
104};
105
106#endif
107// VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h
Critical section locking class.
void Unlock()
Unlock the vtkCriticalSection.
void Lock()
Lock the vtkCriticalSection.
virtual ~vtkSimpleCriticalSection()
int vtkCritSecType