diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-10-12 22:28:35 +0100 |
---|---|---|
committer | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-10-12 22:28:35 +0100 |
commit | d59495110dc5d4924b43926d33c5d29b0103d0e0 (patch) | |
tree | dabf06e88573a20a1522a4b011b91934a53e9b75 /xmrstak/misc | |
parent | b40f937bf592f3fb303ce51fc073ab6ee9f922d0 (diff) | |
download | xmr-stak-d59495110dc5d4924b43926d33c5d29b0103d0e0.zip xmr-stak-d59495110dc5d4924b43926d33c5d29b0103d0e0.tar.gz |
Make sure all singletons are set to null and make env a global ptr
Diffstat (limited to 'xmrstak/misc')
-rw-r--r-- | xmrstak/misc/environment.hpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/xmrstak/misc/environment.hpp b/xmrstak/misc/environment.hpp index 6140d7d..87c512a 100644 --- a/xmrstak/misc/environment.hpp +++ b/xmrstak/misc/environment.hpp @@ -12,35 +12,30 @@ class params; struct environment { - - static environment& inst() - { - static environment env; - return env; - } - - environment& operator=(const environment& env) + static inline environment& inst(environment* init = nullptr) { - this->pPrinter = env.pPrinter; - this->pglobalStates = env.pglobalStates; - this->pJconfConfig = env.pJconfConfig; - this->pExecutor = env.pExecutor; - this->pParams = env.pParams; - return *this; - } + static environment* env = nullptr; + if(env == nullptr) + { + if(init != nullptr) + env = new environment; + else + env = init; + } - environment() : pPrinter(nullptr), pglobalStates(nullptr) - { + return *env; } + environment() + { + } - printer* pPrinter; - globalStates* pglobalStates; - jconf* pJconfConfig; - executor* pExecutor; - params* pParams; - + printer* pPrinter = nullptr; + globalStates* pglobalStates = nullptr; + jconf* pJconfConfig = nullptr; + executor* pExecutor = nullptr; + params* pParams = nullptr; }; } // namepsace xmrstak |