Panda3D
 All Classes Functions Variables Enumerations
conditionVarDebug.h
1 // Filename: conditionVarDebug.h
2 // Created by: drose (13Feb06)
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 CONDITIONVARDEBUG_H
16 #define CONDITIONVARDEBUG_H
17 
18 #include "pandabase.h"
19 #include "pmutex.h"
20 #include "conditionVarImpl.h"
21 
22 #ifdef DEBUG_THREADS
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : ConditionVarDebug
26 // Description : A condition variable, usually used to communicate
27 // information about changing state to a thread that is
28 // waiting for something to happen. A condition
29 // variable can be used to "wake up" a thread when some
30 // arbitrary condition has changed.
31 //
32 // A condition variable is associated with a single
33 // mutex, and several condition variables may share the
34 // same mutex.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_PIPELINE ConditionVarDebug {
37 public:
38  ConditionVarDebug(MutexDebug &mutex);
39  virtual ~ConditionVarDebug();
40 private:
41  INLINE ConditionVarDebug(const ConditionVarDebug &copy);
42  INLINE void operator = (const ConditionVarDebug &copy);
43 
44 PUBLISHED:
45  INLINE MutexDebug &get_mutex() const;
46 
47  BLOCKING void wait();
48  BLOCKING void wait(double timeout);
49  void notify();
50  virtual void output(ostream &out) const;
51 
52 private:
53  MutexDebug &_mutex;
54  ConditionVarImpl _impl;
55 };
56 
57 INLINE ostream &
58 operator << (ostream &out, const ConditionVarDebug &cv) {
59  cv.output(out);
60  return out;
61 }
62 
63 #include "conditionVarDebug.I"
64 
65 #endif // DEBUG_THREADS
66 
67 #endif