chore: rm {accumulator,generator}_service, threads

This commit is contained in:
surtur 2022-01-22 19:27:58 +01:00
parent 52de785399
commit 580531acf2
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 0 additions and 58 deletions

View File

@ -30,10 +30,6 @@ Fortuna::Fortuna() {
this->sync_point.wait(); // wait for init
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);
}
@ -43,12 +39,6 @@ Fortuna::Fortuna() {
}
}
Fortuna::~Fortuna() noexcept {
if (th_gen.joinable()) {
th_gen.join();
}
if (th_accu.joinable()) {
th_accu.join();
}
if (th_sfm.joinable()) {
th_sfm.join();
}
@ -124,47 +114,6 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
} // random_data
auto Fortuna::generator_service(
std::shared_ptr<fortuna::generator::Generator> Gen) -> void {
static constexpr const std::chrono::milliseconds sleep_time{1000};
std::chrono::system_clock::time_point time_point;
{
std::lock_guard<std::mutex> p_ul(print_mtx);
fmt::print("[i] fortuna: starting generator service\n");
}
while (true) {
time_point = fortuna::Util::current_time();
{
std::lock_guard<std::mutex> p_ul(print_mtx);
fmt::print("[*] g: @{}\n", time_point);
}
std::this_thread::sleep_until(time_point +
std::chrono::milliseconds(sleep_time));
}
}
auto Fortuna::accumulator_service() -> void {
static constexpr const std::chrono::seconds sleep_time{10};
std::chrono::system_clock::time_point time_point;
{
std::lock_guard<std::mutex> p_ul(print_mtx);
fmt::print("[i] fortuna: starting accumulator service\n");
}
while (true) {
time_point = fortuna::Util::current_time();
{
std::lock_guard<std::mutex> p_ul(print_mtx);
fmt::print("[*] accu: @{}\n", time_point);
}
std::this_thread::sleep_until(time_point +
std::chrono::seconds(sleep_time));
}
}
auto Fortuna::seed_file_manager_service() -> void {
static constexpr const std::chrono::seconds checkup_interval{10};

View File

@ -24,8 +24,6 @@ public:
std::mutex mtx_p_pools;
mutable std::mutex mtx_accu; // used in const fun, too
std::mutex print_mtx;
std::thread th_gen;
std::thread th_accu;
std::thread th_sfm;
std::thread th_urandom;
std::latch sync_point{1}; // wait for init before spawning the threads
@ -80,11 +78,6 @@ public:
fmt::print("[*] fortuna: PRNG initialized\n");
}
auto generator_service(std::shared_ptr<fortuna::generator::Generator> Gen)
-> void;
auto accumulator_service() -> void;
auto seed_file_manager_service() -> void;
auto urandom_entropy_src_service() -> void;