fortuna: add mtx_{accu,p_pools}, locks

This commit is contained in:
surtur 2022-01-20 08:14:40 +01:00
parent 3b537e1e26
commit 56d9631f84
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 9 additions and 3 deletions

View File

@ -189,9 +189,12 @@ auto Fortuna::seed_file_manager_service() -> void {
p_ul.unlock();
auto right_now{fortuna::Util::current_time()};
std::unique_lock<std::mutex> mtx_l(mtx);
std::unique_lock<std::mutex> a_ul(accu_mtx);
std::unique_lock<std::mutex> a_ul(mtx_accu);
assert(this->accumulator._p_pools_equal(this->R._p_pools));
SeedFileManager sfm(this->accumulator);
a_ul.unlock();
mtx_l.unlock();

View File

@ -21,7 +21,8 @@ public:
static constexpr const char NUM_OF_POOLS{32};
std::mutex mtx;
std::mutex mtx_random_data;
std::mutex accu_mtx;
std::mutex mtx_p_pools;
std::mutex mtx_accu;
std::mutex print_mtx;
std::thread th_gen;
std::thread th_accu;
@ -53,8 +54,10 @@ public:
// p. 153
set_reseed_ctr_to_null();
std::unique_lock<std::mutex> p_ul(print_mtx);
std::unique_lock<std::mutex> a_ul(accu_mtx);
std::unique_lock<std::mutex> a_ul(mtx_accu, std::defer_lock);
std::unique_lock<std::mutex> pp_ul(mtx_p_pools, std::defer_lock);
try {
std::lock(a_ul, pp_ul);
R.initialize_pools();
fmt::print("[i] fortuna: pools initialized\n");
p_ul.unlock();