From b24cf7566a7239fc9c0087ca655ce498e5dceb52 Mon Sep 17 00:00:00 2001 From: surtur Date: Fri, 21 Jan 2022 06:31:46 +0100 Subject: [PATCH] fortuna: move whole ctor code into a try block --- fortuna.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fortuna.cpp b/fortuna.cpp index 94e0dbd..ee662ac 100644 --- a/fortuna.cpp +++ b/fortuna.cpp @@ -27,19 +27,20 @@ auto now{std::chrono::steady_clock::now()}; Fortuna::Fortuna() { try { initialize_prng(); + this->sync_point.wait(); // wait for init + + th_gen = std::thread(&Fortuna::generator_service, + this, + std::make_shared()); + 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); } catch (CryptoPP::Exception& e) { fmt::print(stderr, "{}\n", e.what()); // perhaps die on error } - - th_gen = std::thread(&Fortuna::generator_service, - this, - std::make_shared()); - 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); } Fortuna::~Fortuna() noexcept { if (th_gen.joinable()) {