Split: Expose name via CompThr's derivatives' ctors

This completes the functional work of splitting libspinscale off
from SMO. Spinscale shouldn't have any real dependencies on SMO
from here on out.
This commit is contained in:
2026-02-22 18:54:56 -04:00
parent 1c397dfeb5
commit aec3cbedf2
7 changed files with 21 additions and 16 deletions
+4 -6
View File
@@ -1,12 +1,10 @@
#include <stdexcept>
#include <string>
#include <iostream>
#include <pthread.h>
#include <componentThread.h>
namespace sscl {
namespace smo {
std::string ComponentThread::getThreadName(sscl::ThreadId id)
std::string getThreadName(sscl::ThreadId id)
{
// Cast ThreadId to SmoThreadId for validation and lookup
smo::SmoThreadId smoId = static_cast<smo::SmoThreadId>(id);
@@ -16,7 +14,7 @@ std::string ComponentThread::getThreadName(sscl::ThreadId id)
+ ": Invalid thread ID");
}
// Use function-local static to ensure proper initialization order
// Use function-local static to ensure proper construction order.
static const std::string threadNames[static_cast<int>(smo::SmoThreadId::N_ITEMS)]
= {
"mrntt",
@@ -30,4 +28,4 @@ std::string ComponentThread::getThreadName(sscl::ThreadId id)
return threadNames[static_cast<int>(smoId)];
}
} // namespace sscl
} // namespace smo
+2
View File
@@ -26,6 +26,8 @@ enum SmoThreadId : sscl::ThreadId
N_ITEMS
};
std::string getThreadName(sscl::ThreadId id);
} // namespace smo
#endif // SMO_COMPONENT_THREAD_H
+5 -2
View File
@@ -11,10 +11,13 @@ class MindThread
{
public:
MindThread(
sscl::ThreadId _id, sscl::PuppetThread::entryPointFn entryPoint,
sscl::ThreadId _id, std::string name,
sscl::PuppetThread::entryPointFn entryPoint,
sscl::PuppetComponent &component,
sscl::PuppetThread::preJoltHookFn preJoltFn = nullptr)
: sscl::PuppetThread(_id, std::move(entryPoint), component, preJoltFn)
: sscl::PuppetThread(
_id, std::move(name), std::move(entryPoint),
component, preJoltFn)
{}
};
+1 -1
View File
@@ -16,7 +16,7 @@ namespace mrntt {
std::shared_ptr<sscl::PuppeteerThread> thread = std::make_shared<
sscl::PuppeteerThread>(
SmoThreadId::MRNTT,
SmoThreadId::MRNTT, smo::getThreadName(SmoThreadId::MRNTT),
sscl::pptr::PuppeteerComponent::defaultPuppeteerMain,
mrntt, &MarionetteComponent::preJoltHook);
+6 -4
View File
@@ -1,6 +1,7 @@
#include <config.h>
#include <iostream>
#include <opts.h>
#include <componentThread.h>
#include <spinscale/asynchronousContinuation.h>
#include <spinscale/asynchronousLoop.h>
#include <spinscale/callback.h>
@@ -19,24 +20,25 @@ Mind::Mind(void)
: sscl::PuppetApplication(
std::vector<std::shared_ptr<sscl::PuppetThread>>{
std::make_shared<MindThread>(
SmoThreadId::DIRECTOR,
SmoThreadId::DIRECTOR, getThreadName(SmoThreadId::DIRECTOR),
sscl::PuppetComponent::defaultPuppetMain, director,
&MindComponent::preJoltHook),
std::make_shared<MindThread>(
SmoThreadId::SIMULATOR,
SmoThreadId::SIMULATOR, getThreadName(SmoThreadId::SIMULATOR),
sscl::PuppetComponent::defaultPuppetMain, canvas,
&MindComponent::preJoltHook),
std::make_shared<MindThread>(
SmoThreadId::SUBCONSCIOUS,
getThreadName(SmoThreadId::SUBCONSCIOUS),
sscl::PuppetComponent::defaultPuppetMain, subconscious,
&MindComponent::preJoltHook),
std::make_shared<MindThread>(
SmoThreadId::BODY,
SmoThreadId::BODY, getThreadName(SmoThreadId::BODY),
sscl::PuppetComponent::defaultPuppetMain, body,
&MindComponent::preJoltHook)
#ifndef CONFIG_WORLD_USE_BODY_THREAD
, std::make_shared<MindThread>(
SmoThreadId::WORLD,
SmoThreadId::WORLD, getThreadName(SmoThreadId::WORLD),
sscl::PuppetComponent::defaultPuppetMain, world,
&MindComponent::preJoltHook)
#endif
+2 -2
View File
@@ -4,9 +4,9 @@
namespace smo {
void MindComponent::preJoltHook(sscl::PuppetThread &thr)
void MindComponent::preJoltHook(sscl::PuppetThread &self)
{
pthread_setname_np(pthread_self(), thr.name.c_str());
pthread_setname_np(pthread_self(), self.name.c_str());
}
void MindComponent::handleLoopExceptionHook()