libcryfs/random/Random.h
2015-10-22 17:36:03 +02:00

32 lines
726 B
C++

#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 {
class Random {
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;
};
}
#endif