15 #include "reMutexDirect.h"
28 out <<
"ReMutex " << (
void *)
this;
31 #ifndef HAVE_REMUTEXTRUEIMPL
42 do_acquire(
Thread *current_thread) {
45 if (_locking_thread == (
Thread *)NULL) {
47 _locking_thread = current_thread;
49 nassertd(_lock_count == 1) {
52 }
else if (_locking_thread == current_thread) {
56 nassertd(_lock_count > 0) {
62 while (_locking_thread != (
Thread *)NULL) {
66 _locking_thread = current_thread;
68 nassertd(_lock_count == 1) {
73 #endif // !HAVE_REMUTEXTRUEIMPL
75 #ifndef HAVE_REMUTEXTRUEIMPL
86 do_try_acquire(
Thread *current_thread) {
90 if (_locking_thread == (
Thread *)NULL) {
92 _locking_thread = current_thread;
94 nassertd(_lock_count == 1) {
97 }
else if (_locking_thread == current_thread) {
101 nassertd(_lock_count > 0) {
108 _lock_impl.release();
112 #endif // !HAVE_REMUTEXTRUEIMPL
114 #ifndef HAVE_REMUTEXTRUEIMPL
126 _lock_impl.acquire();
130 _lock_impl.release();
133 #elif !defined(NDEBUG)
134 nassertd(_locking_thread != (
Thread *)NULL) {
135 _lock_impl.release();
143 nassertd(_lock_count > 0) {
146 _lock_impl.release();
148 #endif // !HAVE_REMUTEXTRUEIMPL
150 #ifndef HAVE_REMUTEXTRUEIMPL
162 _lock_impl.acquire();
167 ostr << *_locking_thread <<
" attempted to release "
168 << *
this <<
" which it does not own";
169 nassert_raise(ostr.str());
170 _lock_impl.release();
175 nassertd(_lock_count > 0) {
179 if (_lock_count == 0) {
181 _locking_thread = (
Thread *)NULL;
184 _lock_impl.release();
186 #endif // !HAVE_REMUTEXTRUEIMPL
188 #endif // !DEBUG_THREADS
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
void output(ostream &out) const
This method is declared virtual in MutexDebug, but non-virtual in ReMutexDirect.
A thread; that is, a lightweight process.