Spinscale: create new namespace sscl

This commit is contained in:
2025-12-27 16:21:22 -04:00
parent 0c4f427c0a
commit 34d76df7d9
67 changed files with 434 additions and 429 deletions
+16 -16
View File
@@ -13,13 +13,13 @@ namespace smo {
namespace mrntt {
class MarionetteComponent::MrnttLifetimeMgmtOp
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
: public sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
{
public:
MrnttLifetimeMgmtOp(
MarionetteComponent &parent, const std::shared_ptr<ComponentThread> &caller,
Callback<mrnttLifetimeMgmtOpCbFn> callback)
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
MarionetteComponent &parent, const std::shared_ptr<sscl::ComponentThread> &caller,
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
: sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
caller, callback),
parent(parent)
{}
@@ -32,7 +32,7 @@ public:
[[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context
)
{
auto self = ComponentThread::getSelf();
auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT)
{
throw std::runtime_error(std::string(__func__)
@@ -70,7 +70,7 @@ public:
[[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context
)
{
auto self = ComponentThread::getSelf();
auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT)
{
throw std::runtime_error(std::string(__func__)
@@ -118,12 +118,12 @@ public:
};
class MarionetteComponent::TerminationEvent
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
: public sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
{
public:
TerminationEvent(
const std::shared_ptr<ComponentThread> &caller)
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
const std::shared_ptr<sscl::ComponentThread> &caller)
: sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
caller, {nullptr, nullptr})
{}
@@ -132,7 +132,7 @@ public:
[[maybe_unused]] std::shared_ptr<TerminationEvent> context
)
{
auto self = ComponentThread::getSelf();
auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT)
{
throw std::runtime_error(std::string(__func__)
@@ -146,9 +146,9 @@ public:
};
void MarionetteComponent::initializeReq(
Callback<mrnttLifetimeMgmtOpCbFn> callback)
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
{
auto mrntt = ComponentThread::getSelf();
auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT)
{
@@ -166,9 +166,9 @@ void MarionetteComponent::initializeReq(
}
void MarionetteComponent::finalizeReq(
Callback<mrnttLifetimeMgmtOpCbFn> callback)
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
{
auto mrntt = ComponentThread::getSelf();
auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT)
{
@@ -187,8 +187,8 @@ void MarionetteComponent::finalizeReq(
void MarionetteComponent::exceptionInd()
{
auto faultyThread = ComponentThread::getSelf();
auto mrntt = ComponentThread::getMrntt();
auto faultyThread = sscl::ComponentThread::getSelf();
auto mrntt = sscl::ComponentThread::getMrntt();
auto request = std::make_shared<TerminationEvent>(
faultyThread);
+26 -21
View File
@@ -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