KWStyle - itkSimpleFastMutexLock.cxx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkSimpleFastMutexLock.cxx.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 DEF =========================================================================*/
20 #include "itkSimpleFastMutexLock.h"
21
22 namespace itk
23 {
24
25 // Construct a new SimpleMutexLock 
26 SimpleFastMutexLock::SimpleFastMutexLock()
27 {
28 #ifdef ITK_USE_SPROC
29   init_lock( &m_FastMutexLock );
30 #endif
31
32 #if defined(_WIN32) && !defined(ITK_USE_PTHREADS)
33   //this->MutexLock = CreateMutex( NULL, FALSE, NULL ); 
34   InitializeCriticalSection(&m_FastMutexLock);
35 #endif
36
37 #ifdef ITK_USE_PTHREADS
38 #ifdef ITK_HP_PTHREADS
39   pthread_mutex_init(&(m_FastMutexLock), pthread_mutexattr_default);
40 IND #else
41   pthread_mutex_init(&(m_FastMutexLock), NULL);
42 #endif
43 #endif
44
45 }
46
47 // Destruct the SimpleMutexVariable
48 SimpleFastMutexLock::~SimpleFastMutexLock()
49 {
50 #if defined(_WIN32) && !defined(ITK_USE_PTHREADS)
51   //CloseHandle(this->MutexLock);
52   DeleteCriticalSection(&m_FastMutexLock);
53 #endif
54
55 #ifdef ITK_USE_PTHREADS
56   pthread_mutex_destroy( &m_FastMutexLock);
57 #endif
58 }
59
60 // Lock the FastMutexLock
61 void SimpleFastMutexLock::Lock() const
62 {
63 #ifdef ITK_USE_SPROC
64   spin_lock( &m_FastMutexLock );
65 #endif
66
67 #if defined(_WIN32) && !defined(ITK_USE_PTHREADS)
68   //WaitForSingleObject( this->MutexLock, INFINITE );
69   EnterCriticalSection(&m_FastMutexLock);
70 #endif
71
72 #ifdef ITK_USE_PTHREADS
73   pthread_mutex_lock( &m_FastMutexLock);
74 #endif
75 }
76
77 // Unlock the FastMutexLock
78 void SimpleFastMutexLock::Unlock() const
79 {
80 #ifdef ITK_USE_SPROC
81   release_lock( &m_FastMutexLock );
82 #endif
83
84 #if defined(_WIN32) && !defined(ITK_USE_PTHREADS)
85   //ReleaseMutex( this->MutexLock );
86   LeaveCriticalSection(&m_FastMutexLock);
87 #endif
88
89 #ifdef ITK_USE_PTHREADS
90   pthread_mutex_unlock( &m_FastMutexLock);
91 #endif
92 }
93
94 }//end namespace itk
95

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