forked from ak-fortuna/fortuna
fortuna: update the init-latch logic
This commit is contained in:
parent
6c68efc6ee
commit
c852c723fd
17
fortuna.cpp
17
fortuna.cpp
|
@ -27,25 +27,19 @@ auto now{std::chrono::steady_clock::now()};
|
|||
Fortuna::Fortuna() {
|
||||
try {
|
||||
initialize_prng();
|
||||
this->sync_point.wait(); // wait for init
|
||||
}
|
||||
catch (CryptoPP::Exception& e) {
|
||||
fmt::print(stderr, "{}\n", e.what());
|
||||
// perhaps die on error
|
||||
}
|
||||
|
||||
|
||||
static constexpr const std::chrono::milliseconds duration{150};
|
||||
std::this_thread::sleep_for(duration);
|
||||
|
||||
|
||||
th_gen = std::thread(&Fortuna::generator_service,
|
||||
this,
|
||||
std::make_shared<fortuna::generator::Generator>());
|
||||
th_accu = std::thread(&Fortuna::accumulator_service, this);
|
||||
th_sfm = std::thread(&Fortuna::seed_file_manager_service, this);
|
||||
th_urandom = std::thread(&Fortuna::urandom_entropy_src_service, this);
|
||||
|
||||
this->sync_point.count_down();
|
||||
}
|
||||
Fortuna::~Fortuna() noexcept {
|
||||
if (th_gen.joinable()) {
|
||||
|
@ -134,9 +128,6 @@ auto Fortuna::generator_service(
|
|||
int i{0};
|
||||
static constexpr const std::chrono::milliseconds sleep_time{1000};
|
||||
|
||||
fmt::print("[i] gen: waiting on a latch\n");
|
||||
this->sync_point.count_down();
|
||||
|
||||
std::chrono::system_clock::time_point time_point;
|
||||
std::unique_lock<std::mutex> p_ul(print_mtx);
|
||||
fmt::print("[i] fortuna: starting generator service\n");
|
||||
|
@ -159,9 +150,6 @@ auto Fortuna::generator_service(
|
|||
auto Fortuna::accumulator_service() -> void {
|
||||
static constexpr const std::chrono::seconds sleep_time{10};
|
||||
|
||||
fmt::print("[i] accu: waiting on a latch\n");
|
||||
this->sync_point.count_down();
|
||||
|
||||
std::chrono::system_clock::time_point time_point;
|
||||
std::unique_lock<std::mutex> p_ul(print_mtx);
|
||||
fmt::print("[i] fortuna: starting accumulator service\n");
|
||||
|
@ -180,9 +168,6 @@ auto Fortuna::accumulator_service() -> void {
|
|||
auto Fortuna::seed_file_manager_service() -> void {
|
||||
static constexpr const std::chrono::seconds checkup_interval{10};
|
||||
|
||||
fmt::print("[i] sfm: waiting on a latch\n");
|
||||
this->sync_point.count_down();
|
||||
|
||||
std::unique_lock<std::mutex> p_ul(print_mtx);
|
||||
fmt::print("[i] fortuna: starting seed file manager service\n");
|
||||
fmt::print("[*] sfm: checkup interval {}\n", checkup_interval);
|
||||
|
|
Loading…
Reference in New Issue