summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/globalStates.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xmrstak/backend/globalStates.cpp')
-rw-r--r--xmrstak/backend/globalStates.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/xmrstak/backend/globalStates.cpp b/xmrstak/backend/globalStates.cpp
index 9f41be2..3bd7d0e 100644
--- a/xmrstak/backend/globalStates.cpp
+++ b/xmrstak/backend/globalStates.cpp
@@ -47,20 +47,21 @@ void globalStates::switch_work(miner_work& pWork, pool_data& dat)
{
jobLock.WriteLock();
+ /* This notifies all threads that the job has changed.
+ * To avoid duplicated shared this must be done before the nonce is exchanged.
+ */
+ iGlobalJobNo++;
+
size_t xid = dat.pool_id;
dat.pool_id = pool_id;
pool_id = xid;
/* Maybe a worker thread is updating the nonce while we read it.
- * In that case GPUs check the job ID after a nonce update and in the
- * case that it is a CPU thread we have a small chance (max 6 nonces per CPU thread)
- * that we recalculate a nonce after we reconnect to the current pool
+ * To avoid duplicated share calculations the job ID is checked in the worker thread
+ * after the nonce is read.
*/
dat.iSavedNonce = iGlobalNonce.exchange(dat.iSavedNonce, std::memory_order_relaxed);
oGlobalWork = pWork;
-
- // this notifies all threads that the job has changed
- iGlobalJobNo++;
jobLock.UnLock();
}
OpenPOWER on IntegriCloud