summaryrefslogtreecommitdiffstats
path: root/src/FastRandom.cpp
blob: 5f362a1db4747dd1ab8251629edacb28600f35db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

// FastRandom.cpp


#include "Globals.h"
#include "FastRandom.h"





MTRand & GetRandomProvider()
{
	thread_local MTRand Random = []
	{
		cRandomDeviceSeeder Seeder;
		return MTRand(Seeder);
	}();
	return Random;
}





UInt32 Detail::GetRandomSeed()
{
	thread_local UInt32 SeedCounter = []
	{
		std::random_device rd;
		std::uniform_int_distribution<UInt32> dist;
		return dist(rd);
	}();
	return ++SeedCounter;
}