Cuberite
A lightweight, fast and extensible game server for Minecraft
FastRandom.cpp
Go to the documentation of this file.
1 
2 // FastRandom.cpp
3 
4 
5 #include "Globals.h"
6 #include "FastRandom.h"
7 
8 
9 
10 
11 
13 {
14  thread_local MTRand Random = []
15  {
16  cRandomDeviceSeeder Seeder;
17  return MTRand(Seeder);
18  }();
19  return Random;
20 }
21 
22 
23 
24 
25 
27 {
28  thread_local UInt32 SeedCounter = []
29  {
30  std::random_device rd;
31  std::uniform_int_distribution<UInt32> dist;
32  return dist(rd);
33  }();
34  return ++SeedCounter;
35 }
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Definition: FastRandom.cpp:12
cRandomWrapper< std::mt19937 > MTRand
Definition: FastRandom.h:204
unsigned int UInt32
Definition: Globals.h:157
UInt32 GetRandomSeed()
Returns a low quality seed.
Definition: FastRandom.cpp:26
Class to wrap any random engine to provide a more convenient interface.
Definition: FastRandom.h:58
Utility to seed a random engine with maximal entropy from random_device.
Definition: FastRandom.h:184