Panda3D

lightMutexDirect.I
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 lightMutexDirect.I
10 * @author drose
11 * @date 2008-10-08
12 */
13
14 /**
15 * Alias for acquire() to match C++11 semantics.
16 * @see acquire()
17 */
18 INLINE void LightMutexDirect::
19 lock() {
20 TAU_PROFILE("void LightMutexDirect::acquire()", " ", TAU_USER);
21 _impl.lock();
22 }
23
24 /**
25 * Alias for try_acquire() to match C++11 semantics.
26 * @see try_acquire()
27 */
28 INLINE bool LightMutexDirect::
29 try_lock() {
30 TAU_PROFILE("void LightMutexDirect::try_acquire()", " ", TAU_USER);
31 return _impl.try_lock();
32 }
33
34 /**
35 * Alias for release() to match C++11 semantics.
36 * @see release()
37 */
38 INLINE void LightMutexDirect::
39 unlock() {
40 TAU_PROFILE("void LightMutexDirect::unlock()", " ", TAU_USER);
41 _impl.unlock();
42 }
43
44 /**
45 * Grabs the lightMutex if it is available. If it is not available, blocks
46 * until it becomes available, then grabs it. In either case, the function
47 * does not return until the lightMutex is held; you should then call
48 * unlock().
49 *
50 * This method is considered const so that you can lock and unlock const
51 * lightMutexes, mainly to allow thread-safe access to otherwise const data.
52 *
53 * Also see LightMutexHolder.
54 */
55 INLINE void LightMutexDirect::
56 acquire() const {
57 TAU_PROFILE("void LightMutexDirect::acquire()", " ", TAU_USER);
58 _impl.lock();
59 }
60
61 /**
62 * Releases the lightMutex. It is an error to call this if the lightMutex was
63 * not already locked.
64 *
65 * This method is considered const so that you can lock and unlock const
66 * lightMutexes, mainly to allow thread-safe access to otherwise const data.
67 */
68 INLINE void LightMutexDirect::
69 release() const {
70 TAU_PROFILE("void LightMutexDirect::release()", " ", TAU_USER);
71 _impl.unlock();
72 }
73
74 /**
75 * Returns true if the current thread has locked the LightMutex, false
76 * otherwise. This method is only intended for use in debugging, hence the
77 * method name; in the LightMutexDirect case, it always returns true, since
78 * there's not a reliable way to determine this otherwise.
79 */
80 INLINE bool LightMutexDirect::
81 debug_is_locked() const {
82 return true;
83 }
84
85 /**
86 * The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
87 */
88 INLINE void LightMutexDirect::
89 set_name(const std::string &) {
90 }
91
92 /**
93 * The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
94 */
95 INLINE void LightMutexDirect::
96 clear_name() {
97 }
98
99 /**
100 * The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
101 */
102 INLINE bool LightMutexDirect::
103 has_name() const {
104 return false;
105 }
106
107 /**
108 * The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
109 */
110 INLINE std::string LightMutexDirect::
111 get_name() const {
112 return std::string();
113 }
LightMutexDirect::has_name
bool has_name() const
The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
Definition: lightMutexDirect.I:103
LightMutexDirect::debug_is_locked
bool debug_is_locked() const
Returns true if the current thread has locked the LightMutex, false otherwise.
Definition: lightMutexDirect.I:81
LightMutexDirect::clear_name
void clear_name()
The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
Definition: lightMutexDirect.I:96
LightMutexDirect::unlock
void unlock()
Alias for release() to match C++11 semantics.
Definition: lightMutexDirect.I:39
LightMutexDirect::lock
void lock()
Alias for acquire() to match C++11 semantics.
Definition: lightMutexDirect.I:19
LightMutexDirect::set_name
void set_name(const std::string &name)
The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
Definition: lightMutexDirect.I:89
LightMutexDirect::release
void release() const
Releases the lightMutex.
Definition: lightMutexDirect.I:69
LightMutexDirect::get_name
std::string get_name() const
The lightMutex name is only defined when compiling in DEBUG_THREADS mode.
Definition: lightMutexDirect.I:111
LightMutexDirect::acquire
void acquire() const
Grabs the lightMutex if it is available.
Definition: lightMutexDirect.I:56
LightMutexDirect::try_lock
bool try_lock()
Alias for try_acquire() to match C++11 semantics.
Definition: lightMutexDirect.I:29