diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp index 84f0055..5ca10d3 100644 --- a/xmrstak/backend/amd/minethd.cpp +++ b/xmrstak/backend/amd/minethd.cpp @@ -65,7 +65,7 @@ __declspec(dllexport) #endif std::vector* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env) { - environment::inst() = env; + environment::inst(&env); return amd::minethd::thread_starter(threadOffset, pWork); } } // extern "C" diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index a4aa519..fcd01cd 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -112,7 +112,7 @@ __declspec(dllexport) #endif std::vector* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env) { - environment::inst() = env; + environment::inst(&env); return nvidia::minethd::thread_starter(threadOffset, pWork); } } // extern "C" diff --git a/xmrstak/misc/environment.hpp b/xmrstak/misc/environment.hpp index 85375b0..99c2db8 100644 --- a/xmrstak/misc/environment.hpp +++ b/xmrstak/misc/environment.hpp @@ -12,35 +12,30 @@ struct params; struct environment { + static inline environment& inst(environment* init = nullptr) + { + static environment* env = nullptr; - static environment& inst() - { - static environment env; - return env; - } - - environment& operator=(const environment& env) - { - this->pPrinter = env.pPrinter; - this->pglobalStates = env.pglobalStates; - this->pJconfConfig = env.pJconfConfig; - this->pExecutor = env.pExecutor; - this->pParams = env.pParams; - return *this; + if(env == nullptr) + { + if(init == nullptr) + env = new environment; + else + env = init; + } + + return *env; } - - environment() : pPrinter(nullptr), pglobalStates(nullptr) + 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