diff options
author | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-09-27 16:22:34 +0200 |
---|---|---|
committer | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-09-30 23:46:08 +0200 |
commit | b1e92092bb5c93863d869a2d6b6e057918a77b2f (patch) | |
tree | d8a4e434159a12af6542c8302fb26d4860ac2a6d /backend/GlobalStates.hpp | |
parent | ef551cc032716d8cb21ecfdff73bb6c2bc581740 (diff) | |
download | xmr-stak-b1e92092bb5c93863d869a2d6b6e057918a77b2f.zip xmr-stak-b1e92092bb5c93863d869a2d6b6e057918a77b2f.tar.gz |
fix singleton issues on windows
- pass all singletons into the backend libraries
- move some cpu config features from the cpu config file to the global config.txt
- add global jconf to the xported singleton list
Diffstat (limited to 'backend/GlobalStates.hpp')
-rw-r--r-- | backend/GlobalStates.hpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/backend/GlobalStates.hpp b/backend/GlobalStates.hpp index 293009d..a9818ba 100644 --- a/backend/GlobalStates.hpp +++ b/backend/GlobalStates.hpp @@ -1,6 +1,7 @@ #pragma once #include <atomic> #include "miner_work.h" +#include "../Environment.hpp" namespace xmrstak { @@ -8,12 +9,26 @@ namespace xmrstak struct GlobalStates { - static void switch_work(miner_work& pWork); + static inline GlobalStates& inst() + { + auto& env = Environment::inst(); + if(env.pGlobalStates == nullptr) + env.pGlobalStates = new GlobalStates; + return *env.pGlobalStates; + } - static miner_work oGlobalWork; - static std::atomic<uint64_t> iGlobalJobNo; - static std::atomic<uint64_t> iConsumeCnt; - static uint64_t iThreadCount; + void switch_work(miner_work& pWork); + + miner_work oGlobalWork; + std::atomic<uint64_t> iGlobalJobNo; + std::atomic<uint64_t> iConsumeCnt; + uint64_t iThreadCount; + + private: + + GlobalStates() : iThreadCount(0) + { + } }; |