Spinscale: create new namespace sscl
This commit is contained in:
+26
-21
@@ -8,8 +8,9 @@
|
||||
#include <typeinfo>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <spinscale/asynchronousBridge.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
#include <componentThread.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <salmanoff.h>
|
||||
|
||||
@@ -25,14 +26,14 @@ void CrtCommandLineArgs::set(int argc, char *argv[], char *envp[])
|
||||
namespace mrntt {
|
||||
std::atomic<int> exitCode;
|
||||
// Global marionette thread instance
|
||||
std::shared_ptr<MarionetteThread> thread =
|
||||
std::make_shared<MarionetteThread>();
|
||||
MarionetteComponent mrntt(thread);
|
||||
std::shared_ptr<sscl::MarionetteThread> thread =
|
||||
std::make_shared<sscl::MarionetteThread>();
|
||||
MarionetteComponent mrntt(std::static_pointer_cast<sscl::ComponentThread>(thread));
|
||||
|
||||
void exitMarionetteLoop()
|
||||
{
|
||||
mrntt::thread->keepLooping = false;
|
||||
mrntt::thread->getIoService().stop();
|
||||
thread->keepLooping = false;
|
||||
thread->getIoService().stop();
|
||||
std::cout << "Mrntt: Signaled main loop to exit." << "\n";
|
||||
}
|
||||
|
||||
@@ -65,6 +66,10 @@ void marionetteInitializeReqCb(bool success)
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
} // namespace smo
|
||||
|
||||
namespace sscl {
|
||||
|
||||
void MarionetteThread::main(MarionetteThread& self)
|
||||
{
|
||||
std::string threadName = "smo:" + self.name;
|
||||
@@ -73,7 +78,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
std::cout << __func__ << ": Waiting for command line JOLT" << std::endl;
|
||||
self.getIoService().run();
|
||||
self.initializeTls();
|
||||
mrntt::exitCode = EXIT_SUCCESS;
|
||||
smo::mrntt::exitCode = EXIT_SUCCESS;
|
||||
static boost::asio::signal_set signals(self.getIoService(), SIGINT);
|
||||
bool callShutdownSalmanoff = false;
|
||||
|
||||
@@ -95,8 +100,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
smo::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
);
|
||||
@@ -107,8 +112,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
<< std::endl;
|
||||
|
||||
options.parseArguments(
|
||||
crtCommandLineArgs.argc, crtCommandLineArgs.argv,
|
||||
crtCommandLineArgs.envp);
|
||||
smo::crtCommandLineArgs.argc, smo::crtCommandLineArgs.argv,
|
||||
smo::crtCommandLineArgs.envp);
|
||||
|
||||
std::cout << __func__ << ": " << options.stringifyOptions()
|
||||
<< std::endl;
|
||||
@@ -135,12 +140,12 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
* The latter is cleaner and more resource-respecting. The former is
|
||||
* easier to implement.
|
||||
*/
|
||||
initializeSalmanoff();
|
||||
smo::initializeSalmanoff();
|
||||
callShutdownSalmanoff = true;
|
||||
|
||||
// Create new Mind instance just before initializeReq
|
||||
mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
smo::mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
|
||||
std::cout << __func__ << ": Entering event loop" << "\n";
|
||||
|
||||
@@ -183,8 +188,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (sendExceptionInd)
|
||||
{
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
mrntt::mrntt.exceptionInd();
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +202,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (typeid(e) == typeid(OptionsParserError))
|
||||
{
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
out = &std::cerr;
|
||||
outUsageMsg = std::string(__func__) + ": ";
|
||||
}
|
||||
@@ -208,17 +213,17 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
{
|
||||
std::cerr << __func__ << ": Exception occurred: " << e.what()
|
||||
<< std::endl;
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
||||
mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (callShutdownSalmanoff) {
|
||||
shutdownSalmanoff();
|
||||
smo::shutdownSalmanoff();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace smo
|
||||
} // namespace sscl
|
||||
|
||||
Reference in New Issue
Block a user