KWStyle - itkFastMutexLock.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkFastMutexLock.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:35 $
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 __itkFastMutexLock_h
21 #define __itkFastMutexLock_h
22
23 #include "itkObject.h"
24 #include "itkSimpleFastMutexLock.h"
25 #include "itkObjectFactory.h"
26
27 namespace itk
28 {
29
30 /** \class FastMutexLock
31  * \brief Critical section locking class.
32  * 
33  * FastMutexLock allows the locking of variables which are accessed 
34  * through different threads.  This header file also defines 
35  * SimpleFastMutexLock which is not a subclass of Object.
36  * The API is identical to that of MutexLock, and the behavior is
37  * identical as well, except on Windows 9x/NT platforms. The only difference
38  * on these platforms is that MutexLock is more flexible, in that
39  * it works across processes as well as across threads, but also costs
40  * more, in that it evokes a 600-cycle x86 ring transition. The 
41  * FastMutexLock provides a higher-performance equivalent (on 
42  * Windows) but won't work across processes. Since it is unclear how,
43  * in itk, an object at the itk level can be shared across processes
44  * in the first place, one should use FastMutexLock unless one has
45  * a very good reason to use MutexLock. If higher-performance equivalents
46  * for non-Windows platforms (Irix, SunOS, etc) are discovered, they
47  * should replace the implementations in this class
48  *
49  * \ingroup OSSystemObjects
50  */
51 class ITKCommon_EXPORT FastMutexLock : public Object
52 {
53 public:
54   /** Standard class typedefs. */
55   typedef FastMutexLock       Self;
56 TDA   typedef Object  Superclass;
57   typedef SmartPointer<Self>  Pointer;
58 TDA   typedef SmartPointer<const Self>  ConstPointer;
59   
60   /** Method for creation. */
61   itkNewMacro(Self);
62
63   /** Run-time type information. */
64   itkTypeMacro(FastMutexLock,Object);
65
66   /** Lock the itkFastMutexLock. */
67   void Lock( void );
68
69   /** Unlock the FastMutexLock. */
70   void Unlock( void );
71
72 protected:
73   FastMutexLock() {}
74   ~FastMutexLock() {}
75   
76   SimpleFastMutexLock   m_SimpleFastMutexLock;
77   void PrintSelf(std::ostream& os, Indent indent) const;
78   
79 private:
80   FastMutexLock(const Self&); //purposely not implemented
81   void operator=(const Self&); //purposely not implemented
82 };
83
84
85 inline void FastMutexLock::Lock( void )
86 {
87   m_SimpleFastMutexLock.Lock();
88 }
89
90 inline void FastMutexLock::Unlock( void )
91 {
92   m_SimpleFastMutexLock.Unlock();
93 }
94
95
96 }//end itk namespace
97 #endif
98
99 EOF

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:07PM
© Kitware Inc.