Libspinscale: Add separate CMake project config
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
#include <spinscale/callback.h>
|
||||
#include <spinscale/callableTracer.h>
|
||||
#include <spinscale/component.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <componentThread.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
|
||||
namespace smo {
|
||||
namespace sscl {
|
||||
namespace mrntt {
|
||||
|
||||
class MarionetteComponent::MrnttLifetimeMgmtOp
|
||||
@@ -33,13 +33,13 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
smo::mind::globalMind = std::make_shared<Mind>();
|
||||
smo::mind::globalMind = std::make_shared<smo::Mind>();
|
||||
smo::mind::globalMind->initializeReq({context, std::bind(
|
||||
&MrnttLifetimeMgmtOp::initializeReq2,
|
||||
this, context, std::placeholders::_1)});
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
device::DeviceManager::getInstance().initializeDeviceReattacher();
|
||||
smo::device::DeviceManager::getInstance().initializeDeviceReattacher();
|
||||
|
||||
// Call negtrinEventInd on the Director in the final callback
|
||||
smo::mind::globalMind->director.negtrinEventInd();
|
||||
@@ -71,13 +71,13 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
device::DeviceManager::getInstance().finalizeDeviceReattacher();
|
||||
smo::device::DeviceManager::getInstance().finalizeDeviceReattacher();
|
||||
|
||||
/** FIXME:
|
||||
* It may be necessary to add a delay here to ensure that all in-flight
|
||||
@@ -133,24 +133,24 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
};
|
||||
|
||||
void MarionetteComponent::initializeReq(
|
||||
void sscl::mrntt::MarionetteComponent::initializeReq(
|
||||
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
|
||||
{
|
||||
auto mrntt = sscl::ComponentThread::getSelf();
|
||||
|
||||
if (mrntt->id != SmoThreadId::MRNTT)
|
||||
if (mrntt->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
@@ -165,12 +165,12 @@ void MarionetteComponent::initializeReq(
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::finalizeReq(
|
||||
void sscl::mrntt::MarionetteComponent::finalizeReq(
|
||||
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
|
||||
{
|
||||
auto mrntt = sscl::ComponentThread::getSelf();
|
||||
|
||||
if (mrntt->id != SmoThreadId::MRNTT)
|
||||
if (mrntt->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
@@ -185,7 +185,7 @@ void MarionetteComponent::finalizeReq(
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::exceptionInd()
|
||||
void sscl::mrntt::MarionetteComponent::exceptionInd()
|
||||
{
|
||||
auto faultyThread = sscl::ComponentThread::getSelf();
|
||||
auto mrntt = sscl::ComponentThread::getMrntt();
|
||||
@@ -200,4 +200,4 @@ void MarionetteComponent::exceptionInd()
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
} // namespace smo
|
||||
} // namespace sscl
|
||||
|
||||
+24
-21
@@ -9,12 +9,16 @@
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <spinscale/asynchronousBridge.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <componentThread.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <salmanoff.h>
|
||||
|
||||
namespace smo {
|
||||
// Define the global marionette thread instance (declared extern in libspinscale)
|
||||
namespace sscl {
|
||||
namespace mrntt {
|
||||
std::shared_ptr<MarionetteThread> thread = std::make_shared<MarionetteThread>();
|
||||
} // namespace mrntt
|
||||
|
||||
CrtCommandLineArgs crtCommandLineArgs(0, nullptr, nullptr);
|
||||
|
||||
@@ -25,9 +29,6 @@ void CrtCommandLineArgs::set(int argc, char *argv[], char *envp[])
|
||||
|
||||
namespace mrntt {
|
||||
std::atomic<int> exitCode;
|
||||
// Global marionette thread instance
|
||||
std::shared_ptr<sscl::MarionetteThread> thread =
|
||||
std::make_shared<sscl::MarionetteThread>();
|
||||
MarionetteComponent mrntt(std::static_pointer_cast<sscl::ComponentThread>(thread));
|
||||
|
||||
void exitMarionetteLoop()
|
||||
@@ -47,6 +48,10 @@ void marionetteFinalizeReqCb(bool success)
|
||||
std::cout << __func__ << ": Marionette finalized." << '\n';
|
||||
exitMarionetteLoop();
|
||||
}
|
||||
} // namespace mrntt
|
||||
} // namespace sscl
|
||||
|
||||
namespace smo {
|
||||
|
||||
void marionetteInitializeReqCb(bool success)
|
||||
{
|
||||
@@ -59,13 +64,11 @@ void marionetteInitializeReqCb(bool success)
|
||||
std::cerr << __func__ << ": Failed to initialize Marionette. Shutting down."
|
||||
<< '\n';
|
||||
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
} // namespace smo
|
||||
|
||||
namespace sscl {
|
||||
@@ -78,7 +81,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
std::cout << __func__ << ": Waiting for command line JOLT" << std::endl;
|
||||
self.getIoService().run();
|
||||
self.initializeTls();
|
||||
smo::mrntt::exitCode = EXIT_SUCCESS;
|
||||
sscl::mrntt::exitCode = EXIT_SUCCESS;
|
||||
static boost::asio::signal_set signals(self.getIoService(), SIGINT);
|
||||
bool callShutdownSalmanoff = false;
|
||||
|
||||
@@ -100,8 +103,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
smo::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
);
|
||||
@@ -112,8 +115,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
<< std::endl;
|
||||
|
||||
options.parseArguments(
|
||||
smo::crtCommandLineArgs.argc, smo::crtCommandLineArgs.argv,
|
||||
smo::crtCommandLineArgs.envp);
|
||||
sscl::crtCommandLineArgs.argc, sscl::crtCommandLineArgs.argv,
|
||||
sscl::crtCommandLineArgs.envp);
|
||||
|
||||
std::cout << __func__ << ": " << options.stringifyOptions()
|
||||
<< std::endl;
|
||||
@@ -144,8 +147,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
callShutdownSalmanoff = true;
|
||||
|
||||
// Create new Mind instance just before initializeReq
|
||||
smo::mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
sscl::mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&smo::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
|
||||
std::cout << __func__ << ": Entering event loop" << "\n";
|
||||
|
||||
@@ -188,8 +191,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (sendExceptionInd)
|
||||
{
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::mrntt.exceptionInd();
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +205,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (typeid(e) == typeid(OptionsParserError))
|
||||
{
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
out = &std::cerr;
|
||||
outUsageMsg = std::string(__func__) + ": ";
|
||||
}
|
||||
@@ -213,12 +216,12 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
{
|
||||
std::cerr << __func__ << ": Exception occurred: " << e.what()
|
||||
<< std::endl;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (callShutdownSalmanoff) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <spinscale/component.h>
|
||||
#include <nonNeutralQualia.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
|
||||
|
||||
namespace smo {
|
||||
|
||||
Reference in New Issue
Block a user