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