2013-07-29 12:13:03 +01:00
|
|
|
|
|
|
|
|
// FastRandom.cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
#include "FastRandom.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-19 14:10:18 +01:00
|
|
|
|
2017-06-13 20:35:30 +01:00
|
|
|
MTRand & GetRandomProvider()
|
2014-04-07 19:52:35 +02:00
|
|
|
{
|
2020-05-10 17:16:49 +01:00
|
|
|
thread_local MTRand Random = []
|
|
|
|
|
{
|
|
|
|
|
cRandomDeviceSeeder Seeder;
|
|
|
|
|
return MTRand(Seeder);
|
|
|
|
|
}();
|
|
|
|
|
return Random;
|
2014-10-19 14:10:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-13 20:35:30 +01:00
|
|
|
UInt32 Detail::GetRandomSeed()
|
2014-10-19 14:10:18 +01:00
|
|
|
{
|
2020-05-10 17:16:49 +01:00
|
|
|
thread_local UInt32 SeedCounter = []
|
|
|
|
|
{
|
|
|
|
|
std::random_device rd;
|
|
|
|
|
std::uniform_int_distribution<UInt32> dist;
|
|
|
|
|
return dist(rd);
|
|
|
|
|
}();
|
2017-06-13 20:35:30 +01:00
|
|
|
return ++SeedCounter;
|
2014-04-07 19:52:35 +02:00
|
|
|
}
|