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:
+1
-1
Submodule libspinscale updated: a7521f3760...b4b61bb2b6
@@ -1,12 +1,10 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <componentThread.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
|
// Cast ThreadId to SmoThreadId for validation and lookup
|
||||||
smo::SmoThreadId smoId = static_cast<smo::SmoThreadId>(id);
|
smo::SmoThreadId smoId = static_cast<smo::SmoThreadId>(id);
|
||||||
@@ -16,7 +14,7 @@ std::string ComponentThread::getThreadName(sscl::ThreadId id)
|
|||||||
+ ": Invalid thread 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)]
|
static const std::string threadNames[static_cast<int>(smo::SmoThreadId::N_ITEMS)]
|
||||||
= {
|
= {
|
||||||
"mrntt",
|
"mrntt",
|
||||||
@@ -30,4 +28,4 @@ std::string ComponentThread::getThreadName(sscl::ThreadId id)
|
|||||||
return threadNames[static_cast<int>(smoId)];
|
return threadNames[static_cast<int>(smoId)];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sscl
|
} // namespace smo
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ enum SmoThreadId : sscl::ThreadId
|
|||||||
N_ITEMS
|
N_ITEMS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string getThreadName(sscl::ThreadId id);
|
||||||
|
|
||||||
} // namespace smo
|
} // namespace smo
|
||||||
|
|
||||||
#endif // SMO_COMPONENT_THREAD_H
|
#endif // SMO_COMPONENT_THREAD_H
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ class MindThread
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MindThread(
|
MindThread(
|
||||||
sscl::ThreadId _id, sscl::PuppetThread::entryPointFn entryPoint,
|
sscl::ThreadId _id, std::string name,
|
||||||
|
sscl::PuppetThread::entryPointFn entryPoint,
|
||||||
sscl::PuppetComponent &component,
|
sscl::PuppetComponent &component,
|
||||||
sscl::PuppetThread::preJoltHookFn preJoltFn = nullptr)
|
sscl::PuppetThread::preJoltHookFn preJoltFn = nullptr)
|
||||||
: sscl::PuppetThread(_id, std::move(entryPoint), component, preJoltFn)
|
: sscl::PuppetThread(
|
||||||
|
_id, std::move(name), std::move(entryPoint),
|
||||||
|
component, preJoltFn)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace mrntt {
|
|||||||
|
|
||||||
std::shared_ptr<sscl::PuppeteerThread> thread = std::make_shared<
|
std::shared_ptr<sscl::PuppeteerThread> thread = std::make_shared<
|
||||||
sscl::PuppeteerThread>(
|
sscl::PuppeteerThread>(
|
||||||
SmoThreadId::MRNTT,
|
SmoThreadId::MRNTT, smo::getThreadName(SmoThreadId::MRNTT),
|
||||||
sscl::pptr::PuppeteerComponent::defaultPuppeteerMain,
|
sscl::pptr::PuppeteerComponent::defaultPuppeteerMain,
|
||||||
mrntt, &MarionetteComponent::preJoltHook);
|
mrntt, &MarionetteComponent::preJoltHook);
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -1,6 +1,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
|
#include <componentThread.h>
|
||||||
#include <spinscale/asynchronousContinuation.h>
|
#include <spinscale/asynchronousContinuation.h>
|
||||||
#include <spinscale/asynchronousLoop.h>
|
#include <spinscale/asynchronousLoop.h>
|
||||||
#include <spinscale/callback.h>
|
#include <spinscale/callback.h>
|
||||||
@@ -19,24 +20,25 @@ Mind::Mind(void)
|
|||||||
: sscl::PuppetApplication(
|
: sscl::PuppetApplication(
|
||||||
std::vector<std::shared_ptr<sscl::PuppetThread>>{
|
std::vector<std::shared_ptr<sscl::PuppetThread>>{
|
||||||
std::make_shared<MindThread>(
|
std::make_shared<MindThread>(
|
||||||
SmoThreadId::DIRECTOR,
|
SmoThreadId::DIRECTOR, getThreadName(SmoThreadId::DIRECTOR),
|
||||||
sscl::PuppetComponent::defaultPuppetMain, director,
|
sscl::PuppetComponent::defaultPuppetMain, director,
|
||||||
&MindComponent::preJoltHook),
|
&MindComponent::preJoltHook),
|
||||||
std::make_shared<MindThread>(
|
std::make_shared<MindThread>(
|
||||||
SmoThreadId::SIMULATOR,
|
SmoThreadId::SIMULATOR, getThreadName(SmoThreadId::SIMULATOR),
|
||||||
sscl::PuppetComponent::defaultPuppetMain, canvas,
|
sscl::PuppetComponent::defaultPuppetMain, canvas,
|
||||||
&MindComponent::preJoltHook),
|
&MindComponent::preJoltHook),
|
||||||
std::make_shared<MindThread>(
|
std::make_shared<MindThread>(
|
||||||
SmoThreadId::SUBCONSCIOUS,
|
SmoThreadId::SUBCONSCIOUS,
|
||||||
|
getThreadName(SmoThreadId::SUBCONSCIOUS),
|
||||||
sscl::PuppetComponent::defaultPuppetMain, subconscious,
|
sscl::PuppetComponent::defaultPuppetMain, subconscious,
|
||||||
&MindComponent::preJoltHook),
|
&MindComponent::preJoltHook),
|
||||||
std::make_shared<MindThread>(
|
std::make_shared<MindThread>(
|
||||||
SmoThreadId::BODY,
|
SmoThreadId::BODY, getThreadName(SmoThreadId::BODY),
|
||||||
sscl::PuppetComponent::defaultPuppetMain, body,
|
sscl::PuppetComponent::defaultPuppetMain, body,
|
||||||
&MindComponent::preJoltHook)
|
&MindComponent::preJoltHook)
|
||||||
#ifndef CONFIG_WORLD_USE_BODY_THREAD
|
#ifndef CONFIG_WORLD_USE_BODY_THREAD
|
||||||
, std::make_shared<MindThread>(
|
, std::make_shared<MindThread>(
|
||||||
SmoThreadId::WORLD,
|
SmoThreadId::WORLD, getThreadName(SmoThreadId::WORLD),
|
||||||
sscl::PuppetComponent::defaultPuppetMain, world,
|
sscl::PuppetComponent::defaultPuppetMain, world,
|
||||||
&MindComponent::preJoltHook)
|
&MindComponent::preJoltHook)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
namespace smo {
|
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()
|
void MindComponent::handleLoopExceptionHook()
|
||||||
|
|||||||
Reference in New Issue
Block a user