Rework: Modularize Mind

Now we have modularized the Mind class to contain all of its
ComponentThreads. This enables us to run multiple mind instances
within the same SMO process, at least in theory.

We probably won't actually do this, but we want to ensure that the
design is clean enough to enable it.
This commit is contained in:
2025-09-03 14:43:00 -04:00
parent eb069c4a96
commit 0dc8abaa28
6 changed files with 292 additions and 305 deletions
+12 -4
View File
@@ -3,15 +3,22 @@
#include <iostream>
#include <exception>
#include <opts.h>
#include <typeinfo>
#include <boost/asio/signal_set.hpp>
#include <mind.h>
#include <componentThread.h>
#include <marionette/marionette.h>
#include <salmanoff.h>
#include <boost/asio/signal_set.hpp>
#include <typeinfo>
namespace smo {
// Global Mind instance
std::shared_ptr<Mind> globalMind = std::make_shared<Mind>();
// Global marionette thread instance
std::shared_ptr<ComponentThread> mrntt::mrntt =
std::make_shared<ComponentThread>(ComponentThread::MRNTT, *globalMind);
CrtCommandLineArgs crtCommandLineArgs(0, nullptr, nullptr);
void CrtCommandLineArgs::set(int argc, char *argv[], char *envp[])
@@ -71,7 +78,8 @@ void ComponentThread::marionetteMain(ComponentThread& self)
initializeSalmanoff();
self.getIoService().post([]()
{
mind.initialize();
// Initialize the global Mind object
globalMind->initialize();
});
std::cout << __func__ << ": Entering event loop" << "\n";
@@ -143,7 +151,7 @@ void ComponentThread::marionetteMain(ComponentThread& self)
if (callFinalizeReq)
{
mind.finalizeReq([]{
globalMind->finalizeReq([]{
mrntt::mrntt->getIoService().stop();
});
self.getIoService().reset();