Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlConditionVariable.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Open IGT Link Library
4  Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlConditionVariable.h $
5  Language: C++
6  Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
7  Version: $Reivision$
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notices for more information.
14 
15 =========================================================================*/
16 /*=========================================================================
17 
18  Program: Insight Segmentation & Registration Toolkit
19  Module: $RCSfile: itkConditionVariable.h,v $
20  Language: C++
21  Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
22  Version: $Revision: 3460 $
23 
24  Copyright (c) Insight Software Consortium. All rights reserved.
25  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
26 
27  This software is distributed WITHOUT ANY WARRANTY; without even
28  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
29  PURPOSE. See the above copyright notices for more information.
30 
31 =========================================================================*/
32 #ifndef __igtlConditionVariable_h
33 #define __igtlConditionVariable_h
34 
35 #include "igtlConfigure.h"
36 
37 // This implementation uses a routine called SignalObjectAndWait()
38 // which is only defined on WinNT 4.0 or greater systems. We need to
39 // define this symbol in order to get the prototype for the
40 // routine. This needs to be done before we load any system headers.
41 #ifdef OpenIGTLink_USE_WIN32_THREADS
42 #undef _WIN32_WINNT
43 #define _WIN32_WINNT 0x0400
44 #include "igtlWindows.h"
45 #endif
46 
47 
48 #include "igtlMutexLock.h"
49 #include "igtlLightObject.h"
50 
51 
52 namespace igtl {
53 
85 {
86 public:
92 
95 
98 
102  void Wait(SimpleMutexLock * mutex);
103 
105  void Signal();
106 
108  void Broadcast();
109 
110 protected:
113 
114 private:
115  ConditionVariable(const Self & other);
116  const Self & operator=( const Self & );
117 #ifdef OpenIGTLink_USE_PTHREADS
118  pthread_cond_t m_ConditionVariable;
119  MutexType m_Mutex;
120 #else
121  int m_NumberOfWaiters; // number of waiting threads
122 #ifdef WIN32
123  CRITICAL_SECTION m_NumberOfWaitersLock; // Serialize access to
124  // m_NumberOfWaiters
125 
126  HANDLE m_Semaphore; // Semaphore to queue threads
127  HANDLE m_WaitersAreDone; // Auto-reset event used by the
128  // broadcast/signal thread to
129  // wait for all the waiting
130  // threads to wake up and
131  // release the semaphore
132 
133  size_t m_WasBroadcast; // Keeps track of whether we
134  // were broadcasting or signaling
135 #endif
136 #endif
137 };
138 
139 } // end namespace igtl
140 
141 #endif
142 

Generated at Thu Mar 20 2014 16:32:06 for OpenIGTLink by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2000