VTK
vtkMutexLock.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMutexLock.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 =========================================================================*/
26 #ifndef vtkMutexLock_h
27 #define vtkMutexLock_h
28 
29 
30 #include "vtkCommonCoreModule.h" // For export macro
31 #include "vtkObject.h"
32 
33 //BTX
34 
35 #ifdef VTK_USE_SPROC
36 #include <abi_mutex.h> // Needed for SPROC implementation of mutex
37 typedef abilock_t vtkMutexType;
38 #endif
39 
40 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
41 #include <pthread.h> // Needed for PTHREAD implementation of mutex
42 typedef pthread_mutex_t vtkMutexType;
43 #endif
44 
45 #ifdef VTK_USE_WIN32_THREADS
46 typedef vtkWindowsHANDLE vtkMutexType;
47 #endif
48 
49 #ifndef VTK_USE_SPROC
50 #ifndef VTK_USE_PTHREADS
51 #ifndef VTK_USE_WIN32_THREADS
52 typedef int vtkMutexType;
53 #endif
54 #endif
55 #endif
56 
57 // Mutex lock that is not a vtkObject.
59 {
60 public:
61  // left public purposely
63  virtual ~vtkSimpleMutexLock();
64 
65  static vtkSimpleMutexLock *New();
66 
67  void Delete() {delete this;}
68 
70  void Lock( void );
71 
73  void Unlock( void );
74 
75 protected:
78 
79 private:
80  vtkSimpleMutexLock(const vtkSimpleMutexLock& other); // no copy constructor
81  vtkSimpleMutexLock& operator=(const vtkSimpleMutexLock& rhs); // no copy assignment
82 };
83 
84 //ETX
85 
87 {
88 public:
89  static vtkMutexLock *New();
90 
91  vtkTypeMacro(vtkMutexLock,vtkObject);
92  void PrintSelf(ostream& os, vtkIndent indent);
93 
95  void Lock( void );
96 
98  void Unlock( void );
99 
100 protected:
101  //BTX
102  friend class vtkConditionVariable; // needs to get at SimpleMutexLock.
103  //ETX
104 
107 private:
108  vtkMutexLock(const vtkMutexLock&); // Not implemented.
109  void operator=(const vtkMutexLock&); // Not implemented.
110 };
111 
112 
113 inline void vtkMutexLock::Lock( void )
114 {
115  this->SimpleMutexLock.Lock();
116 }
117 
118 inline void vtkMutexLock::Unlock( void )
119 {
120  this->SimpleMutexLock.Unlock();
121 }
122 
123 #endif
mutual exclusion locking class
abstract base class for most VTK objects
Definition: vtkObject.h:61
void Unlock(void)
Definition: vtkMutexLock.h:118
#define VTKCOMMONCORE_EXPORT
void Lock(void)
Definition: vtkMutexLock.h:113
vtkMutexType MutexLock
Definition: vtkMutexLock.h:77
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkSimpleMutexLock SimpleMutexLock
Definition: vtkMutexLock.h:105
static vtkObject * New()
mutual exclusion locking class
Definition: vtkMutexLock.h:86
int vtkMutexType
Definition: vtkMutexLock.h:52