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 "vtkObject.h"
31 
32 //BTX
33 
34 #ifdef VTK_USE_SPROC
35 #include <abi_mutex.h> // Needed for SPROC implementation of mutex
36 typedef abilock_t vtkMutexType;
37 #endif
38 
39 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
40 #include <pthread.h> // Needed for PTHREAD implementation of mutex
41 typedef pthread_mutex_t vtkMutexType;
42 #endif
43 
44 #ifdef VTK_USE_WIN32_THREADS
45 typedef vtkWindowsHANDLE vtkMutexType;
46 #endif
47 
48 #ifndef VTK_USE_SPROC
49 #ifndef VTK_USE_PTHREADS
50 #ifndef VTK_USE_WIN32_THREADS
51 typedef int vtkMutexType;
52 #endif
53 #endif
54 #endif
55 
56 // Mutex lock that is not a vtkObject.
58 {
59 public:
60  // left public purposely
62  virtual ~vtkSimpleMutexLock();
63 
64  static vtkSimpleMutexLock *New();
65 
66  void Delete() {delete this;}
67 
69  void Lock( void );
70 
72  void Unlock( void );
73 
74 protected:
77 };
78 
79 //ETX
80 
82 {
83 public:
84  static vtkMutexLock *New();
85 
86  vtkTypeMacro(vtkMutexLock,vtkObject);
87  void PrintSelf(ostream& os, vtkIndent indent);
88 
90  void Lock( void );
91 
93  void Unlock( void );
94 
95 protected:
96  //BTX
97  friend class vtkConditionVariable; // needs to get at SimpleMutexLock.
98  //ETX
99 
102 private:
103  vtkMutexLock(const vtkMutexLock&); // Not implemented.
104  void operator=(const vtkMutexLock&); // Not implemented.
105 };
106 
107 
108 inline void vtkMutexLock::Lock( void )
109 {
110  this->SimpleMutexLock.Lock();
111 }
112 
113 inline void vtkMutexLock::Unlock( void )
114 {
115  this->SimpleMutexLock.Unlock();
116 }
117 
118 #endif
mutual exclusion locking class
abstract base class for most VTK objects
Definition: vtkObject.h:60
void Unlock(void)
Definition: vtkMutexLock.h:113
void Lock(void)
Definition: vtkMutexLock.h:108
vtkMutexType MutexLock
Definition: vtkMutexLock.h:76
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
#define VTK_COMMON_EXPORT
vtkSimpleMutexLock SimpleMutexLock
Definition: vtkMutexLock.h:100
static vtkObject * New()
mutual exclusion locking class
Definition: vtkMutexLock.h:81
int vtkMutexType
Definition: vtkMutexLock.h:51