VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkSimpleCriticalSection.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCriticalSection.h
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 =========================================================================*/
00035 #ifndef vtkSimpleCriticalSection_h
00036 #define vtkSimpleCriticalSection_h
00037 
00038 #include "vtkCommonCoreModule.h" // For export macro
00039 #include "vtkSystemIncludes.h"
00040 
00041 //BTX
00042 
00043 #ifdef VTK_USE_SPROC
00044 #include <abi_mutex.h> // Needed for sproc implementation of mutex
00045 typedef abilock_t vtkCritSecType;
00046 #endif
00047 
00048 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
00049 #include <pthread.h> // Needed for pthreads implementation of mutex
00050 typedef pthread_mutex_t vtkCritSecType;
00051 #endif
00052 
00053 #ifdef VTK_USE_WIN32_THREADS
00054 # include "vtkWindows.h" // Needed for win32 implementation of mutex
00055 typedef CRITICAL_SECTION vtkCritSecType;
00056 #endif
00057 
00058 #ifndef VTK_USE_SPROC
00059 #ifndef VTK_USE_PTHREADS
00060 #ifndef VTK_USE_WIN32_THREADS
00061 typedef int vtkCritSecType;
00062 #endif
00063 #endif
00064 #endif
00065 
00066 // Critical Section object that is not a vtkObject.
00067 class VTKCOMMONCORE_EXPORT vtkSimpleCriticalSection
00068 {
00069 public:
00070   // Default cstor
00071   vtkSimpleCriticalSection()
00072     {
00073     this->Init();
00074     }
00075   // Construct object locked if isLocked is different from 0
00076   vtkSimpleCriticalSection(int isLocked)
00077     {
00078     this->Init();
00079     if(isLocked)
00080       {
00081       this->Lock();
00082       }
00083     }
00084   // Destructor
00085   virtual ~vtkSimpleCriticalSection();
00086 
00087   void Init();
00088 
00090   void Lock();
00091 
00093   void Unlock();
00094 
00095 protected:
00096   vtkCritSecType   CritSec;
00097 
00098 private:
00099   vtkSimpleCriticalSection(const vtkSimpleCriticalSection& other); // no copy constructor
00100   vtkSimpleCriticalSection& operator=(const vtkSimpleCriticalSection& rhs); // no copy assignment
00101 };
00102 //ETX
00103 
00104 #endif
00105 // VTK-HeaderTest-Exclude: vtkSimpleCriticalSection.h