diff options
| author | OBATA Akio <obache@wizdas.com> | 2024-07-08 16:49:17 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-07-09 11:43:14 +0900 |
| commit | 7f3dda334696efadcd6cc20c9be20288037a3987 (patch) | |
| tree | 165c25b1cb7887233e35b96cfba468650973534d | |
| parent | 75cb448c029096cabeecc0b259e1b8a3bd978e32 (diff) | |
| download | arts-7f3dda33.tar.gz arts-7f3dda33.zip | |
Rename thread mutex related debug flag name
It is used to detect multiple mutex lock, not just for pthread related
debugging.
Signed-off-by: OBATA Akio <obache@wizdas.com>
(cherry picked from commit 4f18860c3386d449de04bd66d57e93b02ba7d0d1)
| -rw-r--r-- | mcop_mt/threads_posix.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/mcop_mt/threads_posix.cpp b/mcop_mt/threads_posix.cpp index 06920b1..e3ae4d2 100644 --- a/mcop_mt/threads_posix.cpp +++ b/mcop_mt/threads_posix.cpp @@ -43,7 +43,7 @@ * define this if you want to protect mutexes against being locked twice by * the same thread */ -#undef PTHREAD_DEBUG +#undef PTHREAD_PREVENT_MULTI_LOCK namespace Arts { @@ -58,7 +58,7 @@ protected: friend class ThreadCondition_impl; pthread_mutex_t mutex; -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK bool have_owner; pthread_t owner; #endif @@ -67,20 +67,20 @@ public: Mutex_impl() { pthread_mutex_init(&mutex, 0); -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK have_owner = false; #endif } void lock() { -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK pthread_t self = pthread_self(); arts_assert(!have_owner || !pthread_equal(owner, self)); #endif pthread_mutex_lock(&mutex); -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(!have_owner); have_owner = true; owner = self; @@ -88,14 +88,14 @@ public: } bool tryLock() { -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK pthread_t self = pthread_self(); arts_assert(!have_owner || !pthread_equal(owner, self)); #endif int result = pthread_mutex_trylock(&mutex); -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK if(result == 0) { arts_assert(!have_owner); @@ -107,7 +107,7 @@ public: } void unlock() { -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(have_owner && pthread_equal(owner, pthread_self())); have_owner = false; #endif @@ -137,7 +137,7 @@ public: if(!have_owner || !pthread_equal(owner, self)) { pthread_mutex_lock(&mutex); -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(count == 0); arts_assert(!have_owner); #endif @@ -155,7 +155,7 @@ public: if(result != 0) return false; -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(count == 0); arts_assert(!have_owner); #endif @@ -167,7 +167,7 @@ public: } void unlock() { -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(have_owner && pthread_equal(owner, pthread_self())); arts_assert(count > 0); #endif @@ -234,7 +234,7 @@ public: pthread_cond_broadcast(&cond); } void wait(Arts::Mutex_impl *mutex) { -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK pthread_t self = pthread_self(); arts_assert(((Mutex_impl *)mutex)->have_owner && pthread_equal(((Mutex_impl *)mutex)->owner, self)); ((Mutex_impl *)mutex)->have_owner = false; @@ -242,7 +242,7 @@ public: pthread_cond_wait(&cond, &((Mutex_impl*)mutex)->mutex); -#ifdef PTHREAD_DEBUG +#ifdef PTHREAD_PREVENT_MULTI_LOCK arts_assert(!((Mutex_impl *)mutex)->have_owner); ((Mutex_impl *)mutex)->have_owner = true; ((Mutex_impl *)mutex)->owner = self; |
