Panda3D
lightReMutexDirect.h
1 // Filename: lightReMutexDirect.h
2 // Created by: drose (08Oct08)
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 LIGHTREMUTEXDIRECT_H
16 #define LIGHTREMUTEXDIRECT_H
17 
18 #include "pandabase.h"
19 #include "mutexImpl.h"
20 #include "reMutexDirect.h"
21 
22 class Thread;
23 
24 #ifndef DEBUG_THREADS
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : LightReMutexDirect
28 // Description : This class implements a standard lightReMutex by making
29 // direct calls to the underlying implementation layer.
30 // It doesn't perform any debugging operations.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_PIPELINE LightReMutexDirect {
33 protected:
34  INLINE LightReMutexDirect();
35  INLINE ~LightReMutexDirect();
36 private:
37  INLINE LightReMutexDirect(const LightReMutexDirect &copy);
38  INLINE void operator = (const LightReMutexDirect &copy);
39 
40 PUBLISHED:
41  BLOCKING INLINE void acquire() const;
42  BLOCKING INLINE void acquire(Thread *current_thread) const;
43  INLINE void elevate_lock() const;
44  INLINE void release() const;
45 
46  INLINE bool debug_is_locked() const;
47 
48  INLINE void set_name(const string &name);
49  INLINE void clear_name();
50  INLINE bool has_name() const;
51  INLINE string get_name() const;
52 
53  void output(ostream &out) const;
54 
55 private:
56 #if defined(HAVE_REMUTEXIMPL) && !defined(DO_PSTATS)
57  ReMutexImpl _impl;
58 
59 #else
60  // If we don't have a reentrant mutex, use the one we hand-rolled in
61  // ReMutexDirect.
62  ReMutexDirect _impl;
63 #endif // HAVE_REMUTEXIMPL
64 };
65 
66 INLINE ostream &
67 operator << (ostream &out, const LightReMutexDirect &m) {
68  m.output(out);
69  return out;
70 }
71 
72 #include "lightReMutexDirect.I"
73 
74 #endif // !DEBUG_THREADS
75 
76 #endif
This class implements a standard lightReMutex by making direct calls to the underlying implementation...
This class implements a standard reMutex by making direct calls to the underlying implementation laye...
Definition: reMutexDirect.h:32
A thread; that is, a lightweight process.
Definition: thread.h:51
void output(ostream &out) const
This method is declared virtual in MutexDebug, but non-virtual in LightReMutexDirect.
A fake mutex implementation for single-threaded applications that don&#39;t need any synchronization cont...