Skip to content
Snippets Groups Projects
Commit d5949511 authored by fireice-uk's avatar fireice-uk
Browse files

Make sure all singletons are set to null and make env a global ptr

parent b40f937b
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ __declspec(dllexport) ...@@ -65,7 +65,7 @@ __declspec(dllexport)
#endif #endif
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env) std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
{ {
environment::inst() = env; environment::inst(&env);
return amd::minethd::thread_starter(threadOffset, pWork); return amd::minethd::thread_starter(threadOffset, pWork);
} }
} // extern "C" } // extern "C"
......
...@@ -112,7 +112,7 @@ __declspec(dllexport) ...@@ -112,7 +112,7 @@ __declspec(dllexport)
#endif #endif
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env) std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
{ {
environment::inst() = env; environment::inst(&env);
return nvidia::minethd::thread_starter(threadOffset, pWork); return nvidia::minethd::thread_starter(threadOffset, pWork);
} }
} // extern "C" } // extern "C"
......
...@@ -12,35 +12,30 @@ class params; ...@@ -12,35 +12,30 @@ class params;
struct environment struct environment
{ {
static inline environment& inst(environment* init = nullptr)
static environment& inst()
{
static environment env;
return env;
}
environment& operator=(const environment& env)
{ {
this->pPrinter = env.pPrinter; static environment* env = nullptr;
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;
}
environment() : pPrinter(nullptr), pglobalStates(nullptr) return *env;
{
} }
environment()
{
}
printer* pPrinter; printer* pPrinter = nullptr;
globalStates* pglobalStates; globalStates* pglobalStates = nullptr;
jconf* pJconfConfig; jconf* pJconfConfig = nullptr;
executor* pExecutor; executor* pExecutor = nullptr;
params* pParams; params* pParams = nullptr;
}; };
} // namepsace xmrstak } // namepsace xmrstak
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment