From ea3073ac00751292fe85caabe97f5a7385b52f63 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Tue, 28 Oct 2014 08:39:56 +0100 Subject: [PATCH] Reverting changes in mutex --- mutex.cc | 24 ------------------------ mutex.h | 4 ---- 2 files changed, 28 deletions(-) diff --git a/mutex.cc b/mutex.cc index 7b36255..a9a32d4 100644 --- a/mutex.cc +++ b/mutex.cc @@ -29,8 +29,6 @@ Mutex::Mutex() { #else my_mutex=CreateMutex(NULL,FALSE,NULL); #endif - my_cur_thread=0; - num_locks=0; } Mutex::~Mutex() { @@ -40,40 +38,18 @@ Mutex::~Mutex() { } void Mutex::Lock() { - if (num_locks> 0) { -#ifndef WIN32 - if (my_cur_thread==(pid_t) syscall(SYS_gettid)) { -#else - if (my_cur_thread==GetCurrentThreadId()) { -#endif - num_locks++; - return; - } - } #ifndef WIN32 pthread_mutex_lock(&my_mutex); - my_cur_thread=syscall(SYS_gettid); #else WaitForSingleObject(my_mutex, INFINITE ); - my_cur_thread=GetCurrentThreadId(); #endif - num_locks++; - } void Mutex::Unlock() { -#ifndef WIN32 - if (my_cur_thread==syscall(SYS_gettid)) num_locks--; -#else - if (my_cur_thread==GetCurrentThreadId()) num_locks--; -#endif - if (num_locks==0) { - my_cur_thread=0; #ifndef WIN32 pthread_mutex_unlock(&my_mutex); #else ReleaseMutex(my_mutex); #endif - } } diff --git a/mutex.h b/mutex.h index bab9f21..21b04b7 100644 --- a/mutex.h +++ b/mutex.h @@ -23,7 +23,6 @@ #ifndef WIN32 #include -#include #else #include #include @@ -41,11 +40,8 @@ public: protected: #ifndef WIN32 pthread_mutex_t my_mutex; - pid_t my_cur_thread; #else HANDLE my_mutex; - DWORD my_cur_thread; #endif - int num_locks; }; #endif -- 2.39.2