mirror of
https://github.com/xmrig/xmrig.git
synced 2024-10-30 04:57:39 +00:00
Change to fetch_xor to make code simpler
This commit is contained in:
parent
a4550f55ea
commit
858463ceba
1 changed files with 4 additions and 4 deletions
|
@ -43,8 +43,8 @@ xmrig::Worker::Worker(size_t id, int64_t affinity, int priority) :
|
|||
|
||||
void xmrig::Worker::storeStats()
|
||||
{
|
||||
// Get next index which is unused now
|
||||
const uint32_t index = (m_index.load(std::memory_order_relaxed) + 1) & 1;
|
||||
// Get index which is unused now
|
||||
const uint32_t index = m_index.load(std::memory_order_relaxed) ^ 1;
|
||||
|
||||
// Fill in the data for that index
|
||||
m_hashCount[index] = m_count;
|
||||
|
@ -52,13 +52,13 @@ void xmrig::Worker::storeStats()
|
|||
|
||||
// Switch to that index
|
||||
// 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
|
||||
{
|
||||
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];
|
||||
timeStamp = m_timestamp[index];
|
||||
|
|
Loading…
Reference in a new issue