smo::Mind instance now global; track & manage JOLT state in Mind
We moved the instance of smo::Mind to global scope. I suppose we'll only support one instance of Mind per SMO process at least for now. We now track the state of Mind threads' JOLT-waiting. This allows us to centralize the Mind thread shutdown logic. Mind::finalizeReq() now takes care of all Mind thread shutdown state logic by tracking whether Mind threads need to be JOLTed first before being told to exit.
This commit is contained in:
@@ -57,29 +57,15 @@ void ComponentThread::marionetteMain(ComponentThread& self)
|
||||
/* We could make RAII guard classes to always shutdown the mind
|
||||
* threads properly in these pre-event loop situations.
|
||||
*/
|
||||
self.getIoService().post([&options]()
|
||||
{
|
||||
ComponentThread::joltAllMindThreadsReq(
|
||||
[&options]()
|
||||
{
|
||||
ComponentThread::exitAllMindThreadsReq(
|
||||
[&options]()
|
||||
{
|
||||
std::cout << __func__ << ": " << options.getUsage()
|
||||
<< '\n';
|
||||
mrntt::mrntt->getIoService().stop();
|
||||
}
|
||||
);
|
||||
});
|
||||
mind.finalizeReq([]{
|
||||
mrntt::mrntt->getIoService().stop();
|
||||
});
|
||||
self.getIoService().reset();
|
||||
self.getIoService().run();
|
||||
return;
|
||||
}
|
||||
|
||||
smo::Mind mind;
|
||||
|
||||
self.getIoService().post([&mind]()
|
||||
self.getIoService().post([]()
|
||||
{
|
||||
try {
|
||||
initializeSalmanoff();
|
||||
@@ -128,7 +114,7 @@ void ComponentThread::marionetteMain(ComponentThread& self)
|
||||
}
|
||||
|
||||
std::cout << __func__ << ": Exited event loop" << "\n";
|
||||
mind.finalize();
|
||||
mind.finalizeReq(nullptr);
|
||||
shutdownSalmanoff();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
||||
Reference in New Issue
Block a user