m_count possible race fix

This commit is contained in:
eaxeax 2021-09-23 12:19:36 +03:00 committed by eaxeax
parent 12690c66d6
commit 26ced53e4d
4 changed files with 8 additions and 5 deletions

View file

@ -49,6 +49,8 @@ protected:
std::atomic<uint32_t> m_index = {};
uint64_t m_hashCount[2] = {};
uint64_t m_timestamp[2] = {};
uint64_t m_count = 0;
};

View file

@ -39,8 +39,6 @@ protected:
inline size_t id() const override { return m_id; }
inline uint32_t node() const { return m_node; }
std::atomic<uint64_t> m_count = {0};
private:
const int64_t m_affinity;
const size_t m_id;

View file

@ -219,8 +219,8 @@ bool xmrig::CpuWorker<N>::selfTest()
template<size_t N>
void xmrig::CpuWorker<N>::hashrateData(uint64_t &hashCount, uint64_t &, uint64_t &rawHashes) const
{
hashCount = m_count;
rawHashes = m_count;
hashCount = m_count.load(std::memory_order_relaxed);
rawHashes = hashCount;
}
@ -332,7 +332,8 @@ void xmrig::CpuWorker<N>::start()
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), job.hasMinerSignature() ? miner_signature_saved : nullptr);
}
}
m_count += N;
m_count.fetch_add(N, std::memory_order_relaxed);
}
if (m_yield) {

View file

@ -90,6 +90,8 @@ private:
# ifdef XMRIG_FEATURE_BENCHMARK
uint32_t m_benchSize = 0;
# endif
std::atomic<uint64_t> m_count = {0};
};