diff options
author | Josh Gargus <jjosh@google.com> | 2016-10-15 15:19:59 -0700 |
---|---|---|
committer | Josh Gargus <jjosh@google.com> | 2016-10-15 15:19:59 -0700 |
commit | 425af5f6b03b66ff14283d4ba9e8c045d453514f (patch) | |
tree | 03f97636d5982ac48bf423abd362d035869b0323 | |
parent | 87a83d684142b14086be25c074eaf7395645ca21 (diff) | |
download | glslang-425af5f6b03b66ff14283d4ba9e8c045d453514f.tar.gz |
Use a recursive mutex.
-rw-r--r-- | glslang/OSDependent/Unix/ossource.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/glslang/OSDependent/Unix/ossource.cpp b/glslang/OSDependent/Unix/ossource.cpp index 0e6d7307..7e84d4eb 100644 --- a/glslang/OSDependent/Unix/ossource.cpp +++ b/glslang/OSDependent/Unix/ossource.cpp @@ -165,10 +165,27 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex) return false; } -static pthread_mutex_t gMutex; -void InitGlobalLock() { pthread_mutex_init(&gMutex, NULL); } -void GetGlobalLock() { pthread_mutex_lock(&gMutex); } -void ReleaseGlobalLock() { pthread_mutex_unlock(&gMutex); } +namespace { +pthread_mutex_t gMutex; +} + +void InitGlobalLock() +{ + pthread_mutexattr_t mutexattr; + pthread_mutexattr_init(&mutexattr); + pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&gMutex, &mutexattr); +} + +void GetGlobalLock() +{ + pthread_mutex_lock(&gMutex); +} + +void ReleaseGlobalLock() +{ + pthread_mutex_unlock(&gMutex); +} // TODO: non-windows: if we need these on linux, flesh them out void* OS_CreateThread(TThreadEntrypoint /*entry*/) |