Panda3D
lightReMutexDirect.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 lightReMutexDirect.h
10  * @author drose
11  * @date 2008-10-08
12  */
13 
14 #ifndef LIGHTREMUTEXDIRECT_H
15 #define LIGHTREMUTEXDIRECT_H
16 
17 #include "pandabase.h"
18 #include "mutexImpl.h"
19 #include "reMutexDirect.h"
20 #include "thread.h"
21 
22 #ifndef DEBUG_THREADS
23 
24 /**
25  * This class implements a standard lightReMutex by making direct calls to the
26  * underlying implementation layer. It doesn't perform any debugging
27  * operations.
28  */
29 class EXPCL_PANDA_PIPELINE LightReMutexDirect {
30 protected:
31  LightReMutexDirect() = default;
32  LightReMutexDirect(const LightReMutexDirect &copy) = delete;
33  ~LightReMutexDirect() = default;
34 
35  void operator = (const LightReMutexDirect &copy) = delete;
36 
37 public:
38  INLINE void lock();
39  INLINE bool try_lock();
40  INLINE void unlock();
41 
42 PUBLISHED:
43  BLOCKING INLINE void acquire() const;
44  BLOCKING INLINE void acquire(Thread *current_thread) const;
45  INLINE void elevate_lock() const;
46  INLINE void release() const;
47 
48  INLINE bool debug_is_locked() const;
49 
50  INLINE void set_name(const std::string &name);
51  INLINE void clear_name();
52  INLINE bool has_name() const;
53  INLINE std::string get_name() const;
54 
55  void output(std::ostream &out) const;
56 
57 private:
58 #ifdef HAVE_REMUTEXTRUEIMPL
59  mutable ReMutexTrueImpl _impl;
60 
61 #else
62  // If we don't have a reentrant mutex, use the one we hand-rolled in
63  // ReMutexDirect.
64  mutable ReMutexDirect _impl;
65 #endif // HAVE_REMUTEXIMPL
66 };
67 
68 INLINE std::ostream &
69 operator << (std::ostream &out, const LightReMutexDirect &m) {
70  m.output(out);
71  return out;
72 }
73 
74 #include "lightReMutexDirect.I"
75 
76 #endif // !DEBUG_THREADS
77 
78 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class implements a standard lightReMutex by making direct calls to the underlying implementation...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class implements a standard reMutex by making direct calls to the underlying implementation laye...
Definition: reMutexDirect.h:29
void output(std::ostream &out) const
This method is declared virtual in MutexDebug, but non-virtual in LightReMutexDirect.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
Definition: thread.h:46