forked from ak-fortuna/fortuna
fortuna: use a proper shared_ptr to Generator
This commit is contained in:
parent
226a5c2c6c
commit
8c3aee1b07
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace fortuna {
|
namespace fortuna {
|
||||||
|
@ -24,7 +25,8 @@ Fortuna::Fortuna() {
|
||||||
catch (CryptoPP::Exception& e) {
|
catch (CryptoPP::Exception& e) {
|
||||||
fmt::print(stderr, "{}\n", e.what());
|
fmt::print(stderr, "{}\n", e.what());
|
||||||
}
|
}
|
||||||
th_gen = std::thread(&Fortuna::generator_service, this, &R.Gen);
|
th_gen = std::thread(&Fortuna::generator_service, this,
|
||||||
|
std::make_shared<fortuna::generator::Generator>());
|
||||||
th_accu = std::thread(&Fortuna::accumulator_service, this);
|
th_accu = std::thread(&Fortuna::accumulator_service, this);
|
||||||
th_sfm = std::thread(&Fortuna::seed_file_manager_service, this);
|
th_sfm = std::thread(&Fortuna::seed_file_manager_service, this);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +92,8 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
||||||
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
|
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
|
||||||
} // random_data
|
} // random_data
|
||||||
|
|
||||||
auto Fortuna::generator_service(fortuna::generator::Generator* Gen) -> void {
|
auto Fortuna::generator_service(
|
||||||
|
std::shared_ptr<fortuna::generator::Generator> Gen) -> void {
|
||||||
int i{0};
|
int i{0};
|
||||||
std::chrono::milliseconds sleep_time{1000};
|
std::chrono::milliseconds sleep_time{1000};
|
||||||
std::chrono::system_clock::time_point time_point;
|
std::chrono::system_clock::time_point time_point;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
@ -61,7 +62,8 @@ public:
|
||||||
fmt::print("PRNG initialized\n");
|
fmt::print("PRNG initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto generator_service(fortuna::generator::Generator*) -> void;
|
auto generator_service(std::shared_ptr<fortuna::generator::Generator> Gen)
|
||||||
|
-> void;
|
||||||
|
|
||||||
auto accumulator_service() -> void;
|
auto accumulator_service() -> void;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue