Panda3D
Loading...
Searching...
No Matches
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 */
29class EXPCL_PANDA_PIPELINE LightReMutexDirect {
30protected:
31 LightReMutexDirect() = default;
32 LightReMutexDirect(const LightReMutexDirect &copy) = delete;
33 ~LightReMutexDirect() = default;
34
35 void operator = (const LightReMutexDirect &copy) = delete;
36
37public:
38 INLINE void lock();
39 INLINE bool try_lock();
40 INLINE void unlock();
41
42PUBLISHED:
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
57private:
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
68INLINE std::ostream &
69operator << (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
This class implements a standard lightReMutex by making direct calls to the underlying implementation...
void set_name(const std::string &name)
The mutex name is only defined when compiling in DEBUG_THREADS mode.
void acquire() const
Grabs the lightReMutex if it is available.
void clear_name()
The mutex name is only defined when compiling in DEBUG_THREADS mode.
std::string get_name() const
The mutex name is only defined when compiling in DEBUG_THREADS mode.
bool debug_is_locked() const
Returns true if the current thread has locked the LightReMutex, false otherwise.
void output(std::ostream &out) const
This method is declared virtual in MutexDebug, but non-virtual in LightReMutexDirect.
bool try_lock()
Alias for try_acquire() to match C++11 semantics.
void elevate_lock() const
This method increments the lock count, assuming the calling thread already holds the lock.
void unlock()
Alias for release() to match C++11 semantics.
void release() const
Releases the lightReMutex.
void lock()
Alias for acquire() to match C++11 semantics.
bool has_name() const
The mutex name is only defined when compiling in DEBUG_THREADS mode.
This class implements a standard reMutex by making direct calls to the underlying implementation laye...
A thread; that is, a lightweight process.
Definition thread.h:46
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.