{,generate_}random_data: use const uint64_t
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bec124e7c8
commit
1da24b13da
|
@ -45,7 +45,7 @@ Fortuna::~Fortuna() noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
auto Fortuna::random_data(const uint64_t n_bytes) -> void {
|
||||||
if (!this->continue_running.load()) {
|
if (!this->continue_running.load()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <latch>
|
#include <latch>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -22,6 +23,7 @@ namespace fortuna {
|
||||||
class Fortuna final {
|
class Fortuna final {
|
||||||
public:
|
public:
|
||||||
static constexpr const char NUM_OF_POOLS{32};
|
static constexpr const char NUM_OF_POOLS{32};
|
||||||
|
static constexpr const uint64_t two_pow_twenty{1048576};
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
std::mutex mtx_random_data;
|
std::mutex mtx_random_data;
|
||||||
std::mutex mtx_p_pools;
|
std::mutex mtx_p_pools;
|
||||||
|
@ -33,7 +35,7 @@ public:
|
||||||
Fortuna();
|
Fortuna();
|
||||||
~Fortuna() noexcept;
|
~Fortuna() noexcept;
|
||||||
|
|
||||||
[[optimize_for_synchronized]] auto random_data(unsigned int) -> void;
|
[[optimize_for_synchronized]] auto random_data(const uint64_t) -> void;
|
||||||
|
|
||||||
auto set_reseed_ctr_to_null() -> void {
|
auto set_reseed_ctr_to_null() -> void {
|
||||||
std::scoped_lock sl(mtx_accu, print_mtx);
|
std::scoped_lock sl(mtx_accu, print_mtx);
|
||||||
|
|
|
@ -150,7 +150,7 @@ auto Generator::generate_blocks(unsigned int k_blocks) -> std::string {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Generator::generate_random_data(const unsigned int& n) -> std::string {
|
auto Generator::generate_random_data(const uint64_t& n) -> std::string {
|
||||||
std::lock_guard<std::recursive_mutex> lg(mtx);
|
std::lock_guard<std::recursive_mutex> lg(mtx);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
~Generator() noexcept;
|
~Generator() noexcept;
|
||||||
|
|
||||||
/* n is the number of random bytes to generate */
|
/* n is the number of random bytes to generate */
|
||||||
auto generate_random_data(const unsigned int& n) -> std::string;
|
auto generate_random_data(const uint64_t& n) -> std::string;
|
||||||
|
|
||||||
auto reseed(const std::string& s) -> void;
|
auto reseed(const std::string& s) -> void;
|
||||||
|
|
||||||
|
|
Reference in New Issue