mirror of
https://github.com/xmrig/xmrig.git
synced 2026-02-02 02:03:03 -05:00
Fix possible race condition in hashrate counting code
Use single atomic operation to switch between data points.
This commit is contained in:
@@ -44,8 +44,7 @@ public:
|
||||
|
||||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t hashCount() const override { return m_hashCount.load(std::memory_order_relaxed); }
|
||||
inline uint64_t timestamp() const override { return m_timestamp.load(std::memory_order_relaxed); }
|
||||
void getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const override;
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
protected:
|
||||
@@ -53,8 +52,9 @@ protected:
|
||||
|
||||
const int64_t m_affinity;
|
||||
const size_t m_id;
|
||||
std::atomic<uint64_t> m_hashCount;
|
||||
std::atomic<uint64_t> m_timestamp;
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
std::atomic<uint32_t> m_index;
|
||||
uint32_t m_node = 0;
|
||||
uint64_t m_count = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user