diff options
author | psychocrypt <psychocryptHPC@gmail.com> | 2018-05-03 20:40:49 +0200 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2018-06-04 21:07:11 +0000 |
commit | c68e94fb7e18d988aeed3924e505d9ccec87363f (patch) | |
tree | d4f5c00ab4b978e8db64f159e81b12690227f478 /xmrstak/backend/globalStates.cpp | |
parent | 74b4e22aabf38286125316c151fbd3bb72d87bcd (diff) | |
download | xmr-stak-c68e94fb7e18d988aeed3924e505d9ccec87363f.zip xmr-stak-c68e94fb7e18d988aeed3924e505d9ccec87363f.tar.gz |
use read write locks to secure job updates
user read write locks to be sure that no job is consumend during the job update
Diffstat (limited to 'xmrstak/backend/globalStates.cpp')
-rw-r--r-- | xmrstak/backend/globalStates.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/xmrstak/backend/globalStates.cpp b/xmrstak/backend/globalStates.cpp index 6058b7a..8de6bfe 100644 --- a/xmrstak/backend/globalStates.cpp +++ b/xmrstak/backend/globalStates.cpp @@ -35,17 +35,17 @@ namespace xmrstak void globalStates::consume_work( miner_work& threadWork, uint64_t& currentJobId) { - jobLock.rdlock(); + jobLock.ReadLock(); threadWork = oGlobalWork; currentJobId = iGlobalJobNo.load(std::memory_order_relaxed); - jobLock.unlock(); + jobLock.UnLock(); } void globalStates::switch_work(miner_work& pWork, pool_data& dat) { - jobLock.wrlock(); + jobLock.WriteLock(); // this notifies all threads that the job has changed iGlobalJobNo++; @@ -62,7 +62,7 @@ void globalStates::switch_work(miner_work& pWork, pool_data& dat) dat.iSavedNonce = iGlobalNonce.exchange(dat.iSavedNonce, std::memory_order_relaxed); oGlobalWork = pWork; - jobLock.unlock(); + jobLock.UnLock(); } } // namespace xmrstak |