Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMutexLock.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMutexLock.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/01/15 18:57:07 $
00007   Version:   $Revision: 1.18 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 #ifndef __itkMutexLock_h
00021 #define __itkMutexLock_h
00022 
00023 #include "itkObject.h"
00024 #include "itkObjectFactory.h"
00025 
00026 #ifdef ITK_USE_SPROC
00027 #include <abi_mutex.h>
00028 #endif
00029 
00030 #ifdef ITK_USE_PTHREADS
00031 #include <pthread.h>
00032 #endif
00033  
00034 #ifdef ITK_USE_WIN32_THREADS
00035 #include "itkWindows.h"
00036 #endif
00037 
00038 namespace itk
00039 {
00040 
00041 #ifdef ITK_USE_SPROC
00042 typedef abilock_t MutexType;
00043 #endif
00044 
00045 #ifdef ITK_USE_PTHREADS
00046 typedef pthread_mutex_t MutexType;
00047 #endif
00048  
00049 #ifdef ITK_USE_WIN32_THREADS
00050 typedef HANDLE MutexType;
00051 #endif
00052 
00053 #ifndef ITK_USE_SPROC
00054 #ifndef ITK_USE_PTHREADS
00055 #ifndef ITK_USE_WIN32_THREADS
00056 typedef int MutexType;
00057 #endif
00058 #endif
00059 #endif
00060 
00070 class ITK_EXPORT SimpleMutexLock
00071 {
00072 public:
00074   typedef SimpleMutexLock       Self;
00075   
00077   SimpleMutexLock();
00078   virtual ~SimpleMutexLock();
00079   
00081   static SimpleMutexLock *New();
00082   void Delete() {delete this;}
00083   
00085   virtual const char *GetNameOfClass() {return "itkSimpleMutexLock";};
00086   
00088   void Lock( void );
00089 
00091   void Unlock( void );
00092 
00093 protected:
00094   MutexType   m_MutexLock;
00095 };
00096 
00106 class ITK_EXPORT MutexLock : public Object
00107 {
00108 public:
00110   typedef MutexLock       Self;
00111   typedef Object  Superclass;
00112   typedef SmartPointer<Self>  Pointer;
00113   typedef SmartPointer<const Self>  ConstPointer;
00114   
00116   itkNewMacro(Self);
00117   
00119   itkTypeMacro(MutexLock,Object);
00120 
00122   void Lock( void );
00123 
00125   void Unlock( void );
00126 
00127 protected:
00128   MutexLock() {}
00129   ~MutexLock() {}
00130   
00131   SimpleMutexLock   m_SimpleMutexLock;
00132   void PrintSelf(std::ostream& os, Indent indent) const;
00133   
00134 private:
00135   MutexLock(const Self&); //purposely not implemented
00136   void operator=(const Self&); //purposely not implemented
00137 };
00138 
00139 
00140 inline void MutexLock::Lock( void )
00141 {
00142   m_SimpleMutexLock.Lock();
00143 }
00144 
00145 inline void MutexLock::Unlock( void )
00146 {
00147   m_SimpleMutexLock.Unlock();
00148 }
00149 
00150 
00151 }//end itk namespace
00152 #endif

Generated at Wed Mar 12 01:13:08 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000