2015-10-22 17:36:03 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CPPUTILS_RANDOM_RANDOM_H
|
|
|
|
#define MESSMER_CPPUTILS_RANDOM_RANDOM_H
|
|
|
|
|
|
|
|
#include "PseudoRandomPool.h"
|
|
|
|
#include "OSRandomGenerator.h"
|
|
|
|
#include "../data/FixedSizeData.h"
|
|
|
|
#include "../data/Data.h"
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
namespace cpputils {
|
2015-11-27 14:05:30 +01:00
|
|
|
class Random final {
|
2015-10-22 17:36:03 +02:00
|
|
|
public:
|
|
|
|
static PseudoRandomPool &PseudoRandom() {
|
|
|
|
std::unique_lock <std::mutex> lock(_mutex);
|
|
|
|
static PseudoRandomPool random;
|
|
|
|
return random;
|
|
|
|
}
|
|
|
|
|
|
|
|
static OSRandomGenerator &OSRandom() {
|
|
|
|
std::unique_lock <std::mutex> lock(_mutex);
|
|
|
|
static OSRandomGenerator random;
|
|
|
|
return random;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static std::mutex _mutex;
|
2015-11-27 14:05:30 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Random);
|
2015-10-22 17:36:03 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|