chore(fortuna): std::mutex -> std::unique_lock
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-06 00:50:28 +01:00
parent a3009709cf
commit 6e62e47d7b
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -42,7 +42,7 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
std::string s; std::string s;
// synchronise reads and writes to the between // synchronise reads and writes to the between
// {generator,accumulator,fortuna} service threads // {generator,accumulator,fortuna} service threads
std::lock_guard<std::mutex> lg(mtx); std::unique_lock<std::mutex> uq_lock(mtx);
const int pools_to_use{ffsll(static_cast<int>(get_reseed_ctr()))}; const int pools_to_use{ffsll(static_cast<int>(get_reseed_ctr()))};
if (R.pools[0].get_s_length() >= min_pool_size && elapsed > R.Gen.reseed_interval) { if (R.pools[0].get_s_length() >= min_pool_size && elapsed > R.Gen.reseed_interval) {
@ -71,6 +71,7 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
n_bytes, n); n_bytes, n);
n.clear(); n.clear();
} }
uq_lock.unlock();
const auto end{std::chrono::system_clock::now()}; const auto end{std::chrono::system_clock::now()};
std::chrono::duration<float> diff = end-start; std::chrono::duration<float> diff = end-start;