From a8a2d3d504a84f26d71aa364a169963a70ce6288 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Mar 2015 21:52:13 +0000 Subject: [PATCH] Use thread_local in cFastRandom --- src/FastRandom.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index ad1390a92..737b13535 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -6,6 +6,12 @@ #include "Globals.h" #include "FastRandom.h" +#ifdef _WIN32 + #define thread_local __declspec(thread) +#endif + +thread_local unsigned int m_Counter = 0; + @@ -86,7 +92,7 @@ public: cFastRandom::cFastRandom(void) : - m_LinearRand(static_cast(std::chrono::system_clock::now().time_since_epoch().count())) + m_LinearRand(m_Counter++) { } @@ -130,7 +136,7 @@ int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End) // MTRand: MTRand::MTRand() : - m_MersenneRand(static_cast(std::chrono::system_clock::now().time_since_epoch().count())) + m_MersenneRand(m_Counter++) { }