Panda3D
conditionVarDebug.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file conditionVarDebug.h
10  * @author drose
11  * @date 2006-02-13
12  */
13 
14 #ifndef CONDITIONVARDEBUG_H
15 #define CONDITIONVARDEBUG_H
16 
17 #include "pandabase.h"
18 #include "pmutex.h"
19 #include "conditionVarImpl.h"
20 
21 #ifdef DEBUG_THREADS
22 
23 /**
24  * A condition variable, usually used to communicate information about
25  * changing state to a thread that is waiting for something to happen. A
26  * condition variable can be used to "wake up" a thread when some arbitrary
27  * condition has changed.
28  *
29  * A condition variable is associated with a single mutex, and several
30  * condition variables may share the same mutex.
31  */
32 class EXPCL_PANDA_PIPELINE ConditionVarDebug {
33 public:
34  explicit ConditionVarDebug(MutexDebug &mutex);
35  ConditionVarDebug(const ConditionVarDebug &copy) = delete;
36  virtual ~ConditionVarDebug();
37 
38  ConditionVarDebug &operator = (const ConditionVarDebug &copy) = delete;
39 
40 PUBLISHED:
41  INLINE MutexDebug &get_mutex() const;
42 
43  BLOCKING void wait();
44  BLOCKING void wait(double timeout);
45  void notify();
46  virtual void output(std::ostream &out) const;
47 
48 private:
49  MutexDebug &_mutex;
50  ConditionVarImpl _impl;
51 };
52 
53 INLINE std::ostream &
54 operator << (std::ostream &out, const ConditionVarDebug &cv) {
55  cv.output(out);
56  return out;
57 }
58 
59 #include "conditionVarDebug.I"
60 
61 #endif // DEBUG_THREADS
62 
63 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.