mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 14:22:38 +02:00
Use thread-safe atomic in perfmon seeder
Also switch to chrono based types.
This commit is contained in:
parent
d61f2bb076
commit
64e1e022ce
@ -19,6 +19,7 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <thread>
|
||||
@ -73,10 +74,11 @@ void RandAddSeedPerfmon(CSHA512& hasher)
|
||||
// Seed with the entire set of perfmon data
|
||||
|
||||
// This can take up to 2 seconds, so only do it every 10 minutes
|
||||
static int64_t nLastPerfmon;
|
||||
if (GetTime() < nLastPerfmon + 10 * 60)
|
||||
return;
|
||||
nLastPerfmon = GetTime();
|
||||
static std::atomic<std::chrono::seconds> last_perfmon{std::chrono::seconds{0}};
|
||||
auto last_time = last_perfmon.load();
|
||||
auto current_time = GetTime<std::chrono::seconds>();
|
||||
if (current_time < last_time + std::chrono::minutes{10}) return;
|
||||
last_perfmon = current_time;
|
||||
|
||||
std::vector<unsigned char> vData(250000, 0);
|
||||
long ret = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user