From 509a70f57facf60ea97b64a2e110c8ca52f1ec0d Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Sat, 18 Jul 2020 19:34:45 +0000 Subject: Core/Threads: Replace Boost TLS with C++11 one (#15782) * Core/Threads: Replace Boost TLS with C++11 one Replace boost::thread_specific_ptr thread-local storage with C++11 thread_local to remove libboost_thread dependency from common project * Fix no-pch build (cherry picked from commit 00b16992f1ae3bf14ab5fe6366028a2b8648bfa0) --- src/common/Utilities/Random.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/common/Utilities/Random.cpp b/src/common/Utilities/Random.cpp index 5a4004b41bd..64b4f0c57d3 100644 --- a/src/common/Utilities/Random.cpp +++ b/src/common/Utilities/Random.cpp @@ -18,23 +18,18 @@ #include "Random.h" #include "Errors.h" #include "SFMTRand.h" -#include +#include #include -static boost::thread_specific_ptr sfmtRand; +static thread_local std::unique_ptr sfmtRand; static RandomEngine engine; static SFMTRand* GetRng() { - SFMTRand* rand = sfmtRand.get(); + if (!sfmtRand) + sfmtRand = std::make_unique(); - if (!rand) - { - rand = new SFMTRand(); - sfmtRand.reset(rand); - } - - return rand; + return sfmtRand.get(); } int32 irand(int32 min, int32 max) -- cgit v1.2.3