diff options
author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-07-18 19:34:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 21:34:45 +0200 |
commit | 00b16992f1ae3bf14ab5fe6366028a2b8648bfa0 (patch) | |
tree | ced68a8d7cdea1a3b7932d8cec8a794e083bdac0 /src | |
parent | e6e5775be83d07c3221d6690f11184246bec4bf1 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Utilities/Random.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/common/Utilities/Random.cpp b/src/common/Utilities/Random.cpp index 0085f0be292..eb1f63f0707 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 <boost/thread/tss.hpp> +#include <memory> #include <random> -static boost::thread_specific_ptr<SFMTRand> sfmtRand; +static thread_local std::unique_ptr<SFMTRand> sfmtRand; static RandomEngine engine; static SFMTRand* GetRng() { - SFMTRand* rand = sfmtRand.get(); + if (!sfmtRand) + sfmtRand = std::make_unique<SFMTRand>(); - if (!rand) - { - rand = new SFMTRand(); - sfmtRand.reset(rand); - } - - return rand; + return sfmtRand.get(); } int32 irand(int32 min, int32 max) |