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: The OpenIGTLink Library
4  Language: C++
5  Web page: http://openigtlink.org/
6 
7  Copyright (c) Insight Software Consortium. All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 =========================================================================*/
14 /*=========================================================================
15 
16  Program: Insight Segmentation & Registration Toolkit
17  Module: $RCSfile: itkConditionVariable.h,v $
18  Language: C++
19  Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
20  Version: $Revision: 3460 $
21 
22  Copyright (c) Insight Software Consortium. All rights reserved.
23  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
24 
25  This software is distributed WITHOUT ANY WARRANTY; without even
26  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
27  PURPOSE. See the above copyright notices for more information.
28 
29 =========================================================================*/
30 #ifndef __igtlConditionVariable_h
31 #define __igtlConditionVariable_h
32 
33 #include "igtlConfigure.h"
34 
35 // This implementation uses a routine called SignalObjectAndWait()
36 // which is only defined on WinNT 4.0 or greater systems. We need to
37 // define this symbol in order to get the prototype for the
38 // routine. This needs to be done before we load any system headers.
39 #ifdef OpenIGTLink_USE_WIN32_THREADS
40 #undef _WIN32_WINNT
41 #define _WIN32_WINNT 0x0400
42 #include "igtlWindows.h"
43 #endif
44 
45 
46 #include "igtlMutexLock.h"
47 #include "igtlLightObject.h"
48 
49 
50 namespace igtl {
51 
83 {
84 public:
90 
93 
96 
100  void Wait(SimpleMutexLock * mutex);
101 
103  void Signal();
104 
106  void Broadcast();
107 
108 protected:
111 
112 private:
113  ConditionVariable(const Self & other);
114  const Self & operator=( const Self & );
115 #ifdef OpenIGTLink_USE_PTHREADS
116  pthread_cond_t m_ConditionVariable;
117  MutexType m_Mutex;
118 #else
119  int m_NumberOfWaiters; // number of waiting threads
120 #ifdef WIN32
121  CRITICAL_SECTION m_NumberOfWaitersLock; // Serialize access to
122  // m_NumberOfWaiters
123 
124  HANDLE m_Semaphore; // Semaphore to queue threads
125  HANDLE m_WaitersAreDone; // Auto-reset event used by the
126  // broadcast/signal thread to
127  // wait for all the waiting
128  // threads to wake up and
129  // release the semaphore
130 
131  size_t m_WasBroadcast; // Keeps track of whether we
132  // were broadcasting or signaling
133 #endif
134 #endif
135 };
136 
137 } // end namespace igtl
138 
139 #endif
int MutexType
Definition: igtlMutexLock.h:69
#define igtlTypeMacro(thisClass, superclass)
Definition: igtlMacro.h:486
#define IGTLCommon_EXPORT
SmartPointer< const Self > ConstPointer
Light weight base class for most igtl classes.
#define igtlNewMacro(x)
Definition: igtlMacro.h:431
A thread synchronization object used to suspend execution until some condition on shared data is met...
SmartPointer< Self > Pointer
Simple mutual exclusion locking class.
Definition: igtlMutexLock.h:83

Generated at Mon Nov 11 2013 00:36:45 for OpenIGTLink by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2012