Panda3D
mutexDirect.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 mutexDirect.h
10  * @author drose
11  * @date 2006-02-13
12  */
13 
14 #ifndef MUTEXDIRECT_H
15 #define MUTEXDIRECT_H
16 
17 #include "pandabase.h"
18 #include "mutexTrueImpl.h"
19 #include "pnotify.h"
20 
21 class Thread;
22 
23 #ifndef DEBUG_THREADS
24 
25 /**
26  * This class implements a standard mutex by making direct calls to the
27  * underlying implementation layer. It doesn't perform any debugging
28  * operations.
29  */
30 class EXPCL_PANDA_PIPELINE MutexDirect {
31 protected:
32  MutexDirect() = default;
33  MutexDirect(const MutexDirect &copy) = delete;
34  ~MutexDirect() = default;
35 
36  void operator = (const MutexDirect &copy) = delete;
37 
38 public:
39  INLINE void lock();
40  INLINE bool try_lock();
41  INLINE void unlock();
42 
43 PUBLISHED:
44  BLOCKING INLINE void acquire() const;
45  BLOCKING INLINE bool try_acquire() const;
46  INLINE void release() const;
47  INLINE bool debug_is_locked() const;
48 
49  INLINE void set_name(const std::string &name);
50  INLINE void clear_name();
51  INLINE bool has_name() const;
52  INLINE std::string get_name() const;
53 
54  void output(std::ostream &out) const;
55 
56 private:
57  mutable MutexTrueImpl _impl;
58 
59  friend class ConditionVarDirect;
60  friend class ConditionVarFullDirect;
61 };
62 
63 INLINE std::ostream &
64 operator << (std::ostream &out, const MutexDirect &m) {
65  m.output(out);
66  return out;
67 }
68 
69 #include "mutexDirect.I"
70 
71 #endif // !DEBUG_THREADS
72 
73 #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.
void output(std::ostream &out) const
This method is declared virtual in MutexDebug, but non-virtual in MutexDirect.
Definition: mutexDirect.cxx:23
A condition variable, usually used to communicate information about changing state to a thread that i...
A thread; that is, a lightweight process.
Definition: thread.h:46
A fake mutex implementation for single-threaded applications that don't need any synchronization cont...
A condition variable, usually used to communicate information about changing state to a thread that i...
This class implements a standard mutex by making direct calls to the underlying implementation layer.
Definition: mutexDirect.h:30