Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkMutexLock.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkMutexLock.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00023 #ifndef __vtkMutexVariable_h
00024 #define __vtkMutexVariable_h
00025 
00026 
00027 #include "vtkObject.h"
00028 
00029 //BTX
00030 
00031 #ifdef VTK_USE_SPROC
00032 #include <abi_mutex.h> // Needed for SPROC implementation of mutex
00033 typedef abilock_t vtkMutexType;
00034 #endif
00035 
00036 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00037 #include <pthread.h> // Needed for PTHREAD implementation of mutex
00038 typedef pthread_mutex_t vtkMutexType;
00039 #endif
00040  
00041 #ifdef VTK_USE_WIN32_THREADS
00042 typedef vtkWindowsHANDLE vtkMutexType;
00043 #endif
00044 
00045 #ifndef VTK_USE_SPROC
00046 #ifndef VTK_USE_PTHREADS
00047 #ifndef VTK_USE_WIN32_THREADS
00048 typedef int vtkMutexType;
00049 #endif
00050 #endif
00051 #endif
00052 
00053 // Mutex lock that is not a vtkObject.
00054 class VTK_COMMON_EXPORT vtkSimpleMutexLock
00055 {
00056 public:
00057   // left public purposely
00058   vtkSimpleMutexLock();
00059   virtual ~vtkSimpleMutexLock();
00060 
00061   static vtkSimpleMutexLock *New();
00062 
00063   void Delete() {delete this;}
00064   
00066   void Lock( void );
00067 
00069   void Unlock( void );
00070 
00071 protected:
00072   vtkMutexType   MutexLock;
00073 };
00074 
00075 //ETX
00076 
00077 class VTK_COMMON_EXPORT vtkMutexLock : public vtkObject
00078 {
00079 public:
00080   static vtkMutexLock *New();
00081 
00082   vtkTypeRevisionMacro(vtkMutexLock,vtkObject);
00083   void PrintSelf(ostream& os, vtkIndent indent);
00084   
00086   void Lock( void );
00087 
00089   void Unlock( void );
00090 
00091 protected:
00092   vtkSimpleMutexLock   SimpleMutexLock;
00093   vtkMutexLock() {};
00094 private:
00095   vtkMutexLock(const vtkMutexLock&);  // Not implemented.
00096   void operator=(const vtkMutexLock&);  // Not implemented.
00097 };
00098 
00099 
00100 inline void vtkMutexLock::Lock( void )
00101 {
00102   this->SimpleMutexLock.Lock();
00103 }
00104 
00105 inline void vtkMutexLock::Unlock( void )
00106 {
00107   this->SimpleMutexLock.Unlock();
00108 }
00109 
00110 #endif

Generated on Mon Jan 21 23:07:17 2008 for VTK by  doxygen 1.4.3-20050530