Panda3D
 All Classes Functions Variables Enumerations
conditionVar.h
1 // Filename: conditionVar.h
2 // Created by: drose (09Aug02)
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 CONDITIONVAR_H
16 #define CONDITIONVAR_H
17 
18 #include "pandabase.h"
19 #include "conditionVarDebug.h"
20 #include "conditionVarDirect.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ConditionVar
24 // Description : A condition variable, usually used to communicate
25 // information about changing state to a thread that is
26 // waiting for something to happen. A condition
27 // variable can be used to "wake up" a thread when some
28 // arbitrary condition has changed.
29 //
30 // The ConditionVar class does not support the full
31 // semantics of POSIX condition variables. In
32 // particular, it does not support the broadcast or
33 // notify_all function. See ConditionVarFull for a more
34 // complete (but possibly more expensive) API.
35 //
36 // A condition variable is associated with a single
37 // mutex, and several condition variables may share the
38 // same mutex.
39 //
40 // This class inherits its implementation either from
41 // ConditionVarDebug or ConditionVarDirect, depending on
42 // the definition of DEBUG_THREADS.
43 ////////////////////////////////////////////////////////////////////
44 #ifdef DEBUG_THREADS
45 class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDebug
46 #else
47 class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDirect
48 #endif // DEBUG_THREADS
49 {
50 PUBLISHED:
51  INLINE ConditionVar(Mutex &mutex);
52  INLINE ~ConditionVar();
53 private:
54  INLINE ConditionVar(const ConditionVar &copy);
55  INLINE void operator = (const ConditionVar &copy);
56 
57  // These methods are inherited from the base class.
58  // INLINE void wait();
59  // INLINE void notify();
60 
61 private:
62  // The notify_all() method is specifically *not* provided by
63  // ConditionVar. Use ConditionVarFull if you need to call this
64  // method.
65  INLINE void notify_all();
66 
67 PUBLISHED:
68  INLINE Mutex &get_mutex() const;
69 };
70 
71 #include "conditionVar.I"
72 
73 #endif
Mutex & get_mutex() const
Returns the mutex associated with this condition variable.
Definition: conditionVar.I:90
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
A condition variable, usually used to communicate information about changing state to a thread that i...
Definition: conditionVar.h:47
ConditionVar(Mutex &mutex)
You must pass in a Mutex to the condition variable constructor.
Definition: conditionVar.I:27
A condition variable, usually used to communicate information about changing state to a thread that i...