mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-08 08:23:34 -05:00
Change to fetch_xor to make code simpler
This commit is contained in:
@@ -43,8 +43,8 @@ xmrig::Worker::Worker(size_t id, int64_t affinity, int priority) :
|
|||||||
|
|
||||||
void xmrig::Worker::storeStats()
|
void xmrig::Worker::storeStats()
|
||||||
{
|
{
|
||||||
// Get next index which is unused now
|
// Get index which is unused now
|
||||||
const uint32_t index = (m_index.load(std::memory_order_relaxed) + 1) & 1;
|
const uint32_t index = m_index.load(std::memory_order_relaxed) ^ 1;
|
||||||
|
|
||||||
// Fill in the data for that index
|
// Fill in the data for that index
|
||||||
m_hashCount[index] = m_count;
|
m_hashCount[index] = m_count;
|
||||||
@@ -52,13 +52,13 @@ void xmrig::Worker::storeStats()
|
|||||||
|
|
||||||
// Switch to that index
|
// Switch to that index
|
||||||
// All data will be in memory by the time it completes thanks to std::memory_order_seq_cst
|
// All data will be in memory by the time it completes thanks to std::memory_order_seq_cst
|
||||||
m_index.fetch_add(1, std::memory_order_seq_cst);
|
m_index.fetch_xor(1, std::memory_order_seq_cst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Worker::getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const
|
void xmrig::Worker::getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const
|
||||||
{
|
{
|
||||||
const uint32_t index = m_index.load(std::memory_order_relaxed) & 1;
|
const uint32_t index = m_index.load(std::memory_order_relaxed);
|
||||||
|
|
||||||
hashCount = m_hashCount[index];
|
hashCount = m_hashCount[index];
|
||||||
timeStamp = m_timestamp[index];
|
timeStamp = m_timestamp[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user