mrntt:main: Get rid of finalizeInd
This leverages the new clean dynamic allocation of the globalMind object to make the mrntt::main and SMO's initialization and shutdown much cleaner. We no longer concern ourselves with shutting down the Mind threads inside of mrntt::main, but rather we leave that state machine to the Mind class and Mrntt component.
This commit is contained in:
@@ -70,12 +70,11 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
self.initializeTls();
|
||||
mrntt::exitCode = EXIT_SUCCESS;
|
||||
static boost::asio::signal_set signals(self.getIoService(), SIGINT);
|
||||
bool callFinalizeReq = false, callShutdownSalmanoff = false;
|
||||
bool callShutdownSalmanoff = false;
|
||||
|
||||
try {
|
||||
// Register SIGINT (Ctrl+C) and SIGSEGV handlers
|
||||
signals.async_wait(
|
||||
[&self](const boost::system::error_code& ec, int signal)
|
||||
signals.async_wait([](const boost::system::error_code& ec, int signal)
|
||||
{
|
||||
if (ec) { return; }
|
||||
|
||||
@@ -201,34 +200,17 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
}
|
||||
|
||||
*out << outUsageMsg << e.what() << std::endl;
|
||||
callFinalizeReq = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << __func__ << ": Exception occurred: " << e.what()
|
||||
<< std::endl;
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
callShutdownSalmanoff = callFinalizeReq = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
callShutdownSalmanoff = callFinalizeReq = true;
|
||||
}
|
||||
|
||||
if (callFinalizeReq)
|
||||
{
|
||||
std::cout << __func__ << ": About call finalizeReq at end of mrnttMain." << '\n';
|
||||
mind::globalMind->finalizeReq([](bool success)
|
||||
{
|
||||
if (!success) {
|
||||
std::cerr << "Failed to finalize Mind object (threads)" << '\n';
|
||||
}
|
||||
mrntt::thread->getIoService().stop();
|
||||
});
|
||||
self.getIoService().reset();
|
||||
self.getIoService().run();
|
||||
}
|
||||
|
||||
if (callShutdownSalmanoff) {
|
||||
|
||||
Reference in New Issue
Block a user