Core/Threads: Replace Boost TLS with C++11 one (#15782)
* Core/Threads: Replace Boost TLS with C++11 one Replace boost::thread_specific_ptr<T> thread-local storage with C++11 thread_local to remove libboost_thread dependency from common project * Fix no-pch build
This commit is contained in:
1 parent
cbd6fb2315
commit
52d9bb2538
1 file changed
+5
-10
@@ -18,23 +18,18 @@
|
|||||||
#include "Random.h"
|
#include "Random.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "SFMTRand.h"
|
#include "SFMTRand.h"
|
||||||
#include <boost/thread/tss.hpp>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
static boost::thread_specific_ptr<SFMTRand> sfmtRand;
|
static thread_local std::unique_ptr<SFMTRand> sfmtRand;
|
||||||
static RandomEngine engine;
|
static RandomEngine engine;
|
||||||
|
|
||||||
static SFMTRand* GetRng()
|
static SFMTRand* GetRng()
|
||||||
{
|
{
|
||||||
SFMTRand* rand = sfmtRand.get();
|
if (!sfmtRand)
|
||||||
|
sfmtRand = std::make_unique<SFMTRand>();
|
||||||
|
|
||||||
if (!rand)
|
return sfmtRand.get();
|
||||||
{
|
|
||||||
rand = new SFMTRand();
|
|
||||||
sfmtRand.reset(rand);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 irand(int32 min, int32 max)
|
int32 irand(int32 min, int32 max)
|
||||||
|
|||||||
Reference in new issue
Block a user