VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.
58 class VTKCOMMONCORE_EXPORT vtkSimpleMutexLock
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 
80 //ETX
81 
82 class VTKCOMMONCORE_EXPORT vtkMutexLock : public vtkObject
83 {
84 public:
85  static vtkMutexLock *New();
86 
87  vtkTypeMacro(vtkMutexLock,vtkObject);
88  void PrintSelf(ostream& os, vtkIndent indent);
89 
91  void Lock( void );
92 
94  void Unlock( void );
95 
96 protected:
97  //BTX
98  friend class vtkConditionVariable; // needs to get at SimpleMutexLock.
99  //ETX
100 
103 private:
104  vtkMutexLock(const vtkMutexLock&); // Not implemented.
105  void operator=(const vtkMutexLock&); // Not implemented.
106 };
107 
108 
109 inline void vtkMutexLock::Lock( void )
110 {
111  this->SimpleMutexLock.Lock();
112 }
113 
114 inline void vtkMutexLock::Unlock( void )
115 {
116  this->SimpleMutexLock.Unlock();
117 }
118 
119 #endif
mutual exclusion locking class
abstract base class for most VTK objects
Definition: vtkObject.h:61
void Unlock(void)
Definition: vtkMutexLock.h:114
void Lock(void)
Definition: vtkMutexLock.h:109
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:101
static vtkObject * New()
mutual exclusion locking class
Definition: vtkMutexLock.h:82
int vtkMutexType
Definition: vtkMutexLock.h:52