summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOBATA Akio <[email protected]>2024-07-08 16:49:17 +0900
committerOBATA Akio <[email protected]>2024-07-08 16:49:17 +0900
commit4f18860c3386d449de04bd66d57e93b02ba7d0d1 (patch)
treea3825d475bd657f4aaad49cfea7dfdd70d8b906b
parentcf0025c38aeee4502d5c50d8350045830abb7706 (diff)
downloadarts-4f18860c3386d449de04bd66d57e93b02ba7d0d1.tar.gz
arts-4f18860c3386d449de04bd66d57e93b02ba7d0d1.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 <[email protected]>
-rw-r--r--mcop_mt/threads_posix.cpp26
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;