summaryrefslogtreecommitdiffstats
path: root/backend/GlobalStates.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/GlobalStates.hpp')
-rw-r--r--backend/GlobalStates.hpp25
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)
+ {
+ }
};
OpenPOWER on IntegriCloud