From aec3cbedf241c179da749805fadd9cf878b6d51b Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sun, 22 Feb 2026 18:54:56 -0400 Subject: [PATCH] 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. --- libspinscale | 2 +- smocore/componentThread.cpp | 10 ++++------ smocore/include/componentThread.h | 2 ++ smocore/include/mindThread.h | 7 +++++-- smocore/marionette/main.cpp | 2 +- smocore/mind.cpp | 10 ++++++---- smocore/mindComponent.cpp | 4 ++-- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/libspinscale b/libspinscale index a7521f3..b4b61bb 160000 --- a/libspinscale +++ b/libspinscale @@ -1 +1 @@ -Subproject commit a7521f376037dd9f5aaae2b9dfc98d793a5f1a54 +Subproject commit b4b61bb2b6d423abe31506440e9188eba2a99135 diff --git a/smocore/componentThread.cpp b/smocore/componentThread.cpp index dd3122b..7b06174 100644 --- a/smocore/componentThread.cpp +++ b/smocore/componentThread.cpp @@ -1,12 +1,10 @@ #include #include -#include -#include #include -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(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(smo::SmoThreadId::N_ITEMS)] = { "mrntt", @@ -30,4 +28,4 @@ std::string ComponentThread::getThreadName(sscl::ThreadId id) return threadNames[static_cast(smoId)]; } -} // namespace sscl +} // namespace smo diff --git a/smocore/include/componentThread.h b/smocore/include/componentThread.h index 632a537..d0e71ac 100644 --- a/smocore/include/componentThread.h +++ b/smocore/include/componentThread.h @@ -26,6 +26,8 @@ enum SmoThreadId : sscl::ThreadId N_ITEMS }; +std::string getThreadName(sscl::ThreadId id); + } // namespace smo #endif // SMO_COMPONENT_THREAD_H diff --git a/smocore/include/mindThread.h b/smocore/include/mindThread.h index 6946a45..74fe23a 100644 --- a/smocore/include/mindThread.h +++ b/smocore/include/mindThread.h @@ -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) {} }; diff --git a/smocore/marionette/main.cpp b/smocore/marionette/main.cpp index d06c246..6a14683 100644 --- a/smocore/marionette/main.cpp +++ b/smocore/marionette/main.cpp @@ -16,7 +16,7 @@ namespace mrntt { std::shared_ptr thread = std::make_shared< sscl::PuppeteerThread>( - SmoThreadId::MRNTT, + SmoThreadId::MRNTT, smo::getThreadName(SmoThreadId::MRNTT), sscl::pptr::PuppeteerComponent::defaultPuppeteerMain, mrntt, &MarionetteComponent::preJoltHook); diff --git a/smocore/mind.cpp b/smocore/mind.cpp index 09ba075..61b5f97 100644 --- a/smocore/mind.cpp +++ b/smocore/mind.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -19,24 +20,25 @@ Mind::Mind(void) : sscl::PuppetApplication( std::vector>{ std::make_shared( - SmoThreadId::DIRECTOR, + SmoThreadId::DIRECTOR, getThreadName(SmoThreadId::DIRECTOR), sscl::PuppetComponent::defaultPuppetMain, director, &MindComponent::preJoltHook), std::make_shared( - SmoThreadId::SIMULATOR, + SmoThreadId::SIMULATOR, getThreadName(SmoThreadId::SIMULATOR), sscl::PuppetComponent::defaultPuppetMain, canvas, &MindComponent::preJoltHook), std::make_shared( SmoThreadId::SUBCONSCIOUS, + getThreadName(SmoThreadId::SUBCONSCIOUS), sscl::PuppetComponent::defaultPuppetMain, subconscious, &MindComponent::preJoltHook), std::make_shared( - SmoThreadId::BODY, + SmoThreadId::BODY, getThreadName(SmoThreadId::BODY), sscl::PuppetComponent::defaultPuppetMain, body, &MindComponent::preJoltHook) #ifndef CONFIG_WORLD_USE_BODY_THREAD , std::make_shared( - SmoThreadId::WORLD, + SmoThreadId::WORLD, getThreadName(SmoThreadId::WORLD), sscl::PuppetComponent::defaultPuppetMain, world, &MindComponent::preJoltHook) #endif diff --git a/smocore/mindComponent.cpp b/smocore/mindComponent.cpp index 5aa0c27..6d484e3 100644 --- a/smocore/mindComponent.cpp +++ b/smocore/mindComponent.cpp @@ -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()