1
0
Fork 0

Use thread_local in cFastRandom

This commit is contained in:
Tiger Wang 2015-03-14 21:52:13 +00:00
parent e94886c140
commit a8a2d3d504
1 changed files with 8 additions and 2 deletions

View File

@ -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<unsigned>(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<unsigned>(std::chrono::system_clock::now().time_since_epoch().count()))
m_MersenneRand(m_Counter++)
{
}