Panda3D
conditionVarWin32Impl.h
1 // Filename: conditionVarWin32Impl.h
2 // Created by: drose (07Feb06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CONDITIONVARWIN32IMPL_H
16 #define CONDITIONVARWIN32IMPL_H
17 
18 #include "pandabase.h"
19 #include "selectThreadImpl.h"
20 
21 #if defined(WIN32_VC)
22 
23 #include "mutexWin32Impl.h"
24 #include "pnotify.h"
25 
26 class MutexWin32Impl;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : ConditionVarWin32Impl
30 // Description : Uses Windows native calls to implement a
31 // conditionVar.
32 //
33 // The Windows native synchronization primitives don't
34 // actually implement a full POSIX-style condition
35 // variable, but the Event primitive does a fair job if
36 // we disallow notify_all() (POSIX broadcast). See
37 // ConditionVarFullWin32Impl for a full implementation
38 // that includes notify_all(). This class is much
39 // simpler than that full implementation, so we can
40 // avoid the overhead required to support broadcast.
41 ////////////////////////////////////////////////////////////////////
42 class EXPCL_PANDA_PIPELINE ConditionVarWin32Impl {
43 public:
44  INLINE ConditionVarWin32Impl(MutexWin32Impl &mutex);
45  INLINE ~ConditionVarWin32Impl();
46 
47  INLINE void wait();
48  INLINE void wait(double timeout);
49  INLINE void notify();
50 
51 private:
52  CRITICAL_SECTION *_external_mutex;
53  HANDLE _event_signal;
54 };
55 
56 #include "conditionVarWin32Impl.I"
57 
58 #endif // WIN32_VC
59 
60 #endif