GH #282: Using Thread in a global can cause crash on Windows

This commit is contained in:
Aleksandar Fabijanic 2014-06-04 10:21:26 -05:00
parent ba0d9830eb
commit b5ce0804a1

View File

@ -146,13 +146,17 @@ std::string Thread::makeName()
namespace namespace
{ {
FastMutex& getUniqueIdMutex()
{
static FastMutex uniqueIdMutex; static FastMutex uniqueIdMutex;
return uniqueIdMutex;
}
} }
int Thread::uniqueId() int Thread::uniqueId()
{ {
FastMutex::ScopedLock lock(uniqueIdMutex); FastMutex::ScopedLock lock(getUniqueIdMutex());
static unsigned count = 0; static unsigned count = 0;
++count; ++count;