fortuna: std::atomic<bool> continue_running

This commit is contained in:
surtur 2022-01-23 20:39:11 +01:00
parent e706de7702
commit 2c56d9af27
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -8,8 +8,10 @@
#include <fmt/core.h>
#include <array>
#include <atomic>
#include <cassert>
#include <chrono>
#include <exception>
#include <latch>
#include <memory>
#include <mutex>
@ -84,6 +86,17 @@ public:
auto urandom_entropy_src_service() -> void;
auto stop_running() -> int {
try {
fmt::print("[i] fortuna: received the stop request...\n");
this->continue_running.store(false);
}
catch (std::exception& e) {
throw;
}
return 0;
}
// PRNG state
class R_state {
friend fortuna::Fortuna;
@ -118,6 +131,7 @@ public:
std::latch sync_point{1}; // wait for init before spawning the threads
std::latch die_point{2}; // wait for service threads to die
std::atomic<bool> continue_running{true};
std::once_flag PRNG_init;
}; // class Fortuna