mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 02:22:57 +01:00
AtomicCounter fix for GH #282: Using Thread in a global can cause crash on Windows
This commit is contained in:
parent
b5ce0804a1
commit
c2704199ae
@ -18,6 +18,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/ThreadLocal.h"
|
||||
#include "Poco/AtomicCounter.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@ -144,23 +145,10 @@ std::string Thread::makeName()
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
FastMutex& getUniqueIdMutex()
|
||||
{
|
||||
static FastMutex uniqueIdMutex;
|
||||
return uniqueIdMutex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Thread::uniqueId()
|
||||
{
|
||||
FastMutex::ScopedLock lock(getUniqueIdMutex());
|
||||
|
||||
static unsigned count = 0;
|
||||
++count;
|
||||
return count;
|
||||
static Poco::AtomicCounter counter;
|
||||
return ++counter;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user