Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Common/vtkMutexLock.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkMutexLock.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00041 #ifndef __vtkMutexVariable_h
    00042 #define __vtkMutexVariable_h
    00043
    00044
    00045 #include "vtkObject.h"
    00046
    00047 //BTX
    00048
    00049 #ifdef VTK_USE_SPROC
    00050 #include <abi_mutex.h> // Needed for SPROC implementation of mutex
    00051 typedef abilock_t vtkMutexType;
    00052 #endif
    00053
    00054 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
    00055 #include <pthread.h> // Needed for PTHREAD implementation of mutex
    00056 typedef pthread_mutex_t vtkMutexType;
    00057 #endif
    00058
    00059 #ifdef VTK_USE_WIN32_THREADS
    00060 #include <winbase.h> // Needed for WIN32 implementation of mutex
    00061 typedef HANDLE vtkMutexType;
    00062 #endif
    00063
    00064 #ifndef VTK_USE_SPROC
    00065 #ifndef VTK_USE_PTHREADS
    00066 #ifndef VTK_USE_WIN32_THREADS
    00067 typedef int vtkMutexType;
    00068 #endif
    00069 #endif
    00070 #endif
    00071
    00072 // Mutex lock that is not a vtkObject.
    00073 class VTK_COMMON_EXPORT vtkSimpleMutexLock
    00074 {
    00075 public:
    00076   // left public purposely
    00077   vtkSimpleMutexLock();
    00078   virtual ~vtkSimpleMutexLock();
    00079
    00080   static vtkSimpleMutexLock *New();
    00081
    00082   virtual const char *GetClassName() {return "vtkSimpleMutexLock";};
    00083   virtual int IsA(const char *name);
    00084   static vtkSimpleMutexLock *SafeDownCast(vtkSimpleMutexLock *o);
    00085
    00086   void Delete() {delete this;}
    00087
    00089   void Lock( void );
    00090
    00092   void Unlock( void );
    00093
    00094 protected:
    00095   vtkMutexType   MutexLock;
    00096 };
    00097
    00098 //ETX
    00099
    00100 class VTK_COMMON_EXPORT vtkMutexLock : public vtkObject
    00101 {
    00102 public:
    00103   static vtkMutexLock *New();
    00104
    00105   vtkTypeRevisionMacro(vtkMutexLock,vtkObject);
    00106   void PrintSelf(ostream& os, vtkIndent indent);
    00107
    00109   void Lock( void );
    00110
    00112   void Unlock( void );
    00113
    00114 protected:
    00115   vtkSimpleMutexLock   SimpleMutexLock;
    00116   vtkMutexLock() {};
    00117 private:
    00118   vtkMutexLock(const vtkMutexLock&);  // Not implemented.
    00119   void operator=(const vtkMutexLock&);  // Not implemented.
    00120 };
    00121
    00122
    00123 inline void vtkMutexLock::Lock( void )
    00124 {
    00125   this->SimpleMutexLock.Lock();
    00126 }
    00127
    00128 inline void vtkMutexLock::Unlock( void )
    00129 {
    00130   this->SimpleMutexLock.Unlock();
    00131 }
    00132
    00133 #endif