| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkSimpleFastMutexLock.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
Portions of this code are covered under the VTK copyright. |
| 13 |
|
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. |
| 14 |
|
|
| 15 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 16 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 17 |
IND |
*****PURPOSE. See the above copyright notices for more information. |
| 18 |
|
|
| 19 |
|
=========================================================================*/ |
| 20 |
|
#ifndef __itkSimpleFastMutexLock_h |
| 21 |
|
#define __itkSimpleFastMutexLock_h |
| 22 |
|
|
| 23 |
|
#include "itkMacro.h" |
| 24 |
|
|
| 25 |
|
#ifdef ITK_USE_SPROC |
| 26 |
|
#include <abi_mutex.h> |
| 27 |
|
#endif |
| 28 |
|
|
| 29 |
|
#ifdef ITK_USE_PTHREADS |
| 30 |
|
#include <pthread.h> |
| 31 |
|
#endif |
| 32 |
|
|
| 33 |
|
#if defined(_WIN32) && !defined(ITK_USE_PTHREADS) |
| 34 |
|
#include "itkWindows.h" |
| 35 |
|
#endif |
| 36 |
|
|
| 37 |
|
namespace itk |
| 38 |
|
{ |
| 39 |
|
|
| 40 |
|
#ifdef ITK_USE_SPROC |
| 41 |
|
#include <abi_mutex.h> |
| 42 |
|
typedef abilock_t FastMutexType; |
| 43 |
|
#endif |
| 44 |
|
|
| 45 |
|
#ifdef ITK_USE_PTHREADS |
| 46 |
|
#include <pthread.h> |
| 47 |
|
typedef pthread_mutex_t FastMutexType; |
| 48 |
|
#endif |
| 49 |
|
|
| 50 |
|
#if defined(_WIN32) && !defined(ITK_USE_PTHREADS) |
| 51 |
|
#include <winbase.h> |
| 52 |
|
typedef CRITICAL_SECTION FastMutexType; |
| 53 |
|
#endif |
| 54 |
|
|
| 55 |
|
#ifndef ITK_USE_SPROC |
| 56 |
|
#ifndef ITK_USE_PTHREADS |
| 57 |
|
#ifndef _WIN32 |
| 58 |
|
typedef int FastMutexType; |
| 59 |
|
#endif |
| 60 |
|
#endif |
| 61 |
|
#endif |
| 62 |
|
|
| 63 |
|
/** \class SimpleFastMutexLock |
| 64 |
|
* \brief Critical section locking class that can be allocated on the stack. |
| 65 |
|
* |
| 66 |
|
* SimpleFastMutexLock is used by FastMutexLock to perform mutex locking. |
| 67 |
|
* SimpleFastMutexLock is not a subclass of Object and is designed to be |
| 68 |
|
* allocated on the stack. |
| 69 |
|
* |
| 70 |
|
* \ingroup OSSystemObjects |
| 71 |
|
*/ |
| 72 |
|
|
| 73 |
|
// Critical Section object that is not a itkObject. |
| 74 |
|
class ITKCommon_EXPORT SimpleFastMutexLock |
| 75 |
|
{ |
| 76 |
|
public: |
| 77 |
|
/** Standard class typedefs. */ |
| 78 |
|
typedef SimpleFastMutexLock Self; |
| 79 |
|
|
| 80 |
LEN |
/** Constructor and destructor left public purposely because of stack allocation. */ |
| 81 |
|
SimpleFastMutexLock(); |
| 82 |
|
~SimpleFastMutexLock(); |
| 83 |
|
|
| 84 |
|
/** Lock access. */ |
| 85 |
|
void Lock( void ) const; |
| 86 |
|
|
| 87 |
|
/** Unlock access. */ |
| 88 |
|
void Unlock( void ) const; |
| 89 |
|
|
| 90 |
|
protected: |
| 91 |
|
mutable FastMutexType m_FastMutexLock; |
| 92 |
|
}; |
| 93 |
|
|
| 94 |
|
}//end itk namespace |
| 95 |
|
#endif |
| 96 |
|
|
| 97 |
EOF |
|