From: Josh Gargus Date: Sat, 15 Oct 2016 22:19:59 +0000 (-0700) Subject: Use a recursive mutex. X-Git-Tag: upstream/11.4.0~1446^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=425af5f6b03b66ff14283d4ba9e8c045d453514f;p=platform%2Fupstream%2Fglslang.git Use a recursive mutex. --- diff --git a/glslang/OSDependent/Unix/ossource.cpp b/glslang/OSDependent/Unix/ossource.cpp index 0e6d730..7e84d4e 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*/)