Improve CONFIG_WORLD_USE_BODY_THREAD handling

We no longer need to do ugly ifdefs in the constructor for
Mind::Mind because we preprocess the handling for BODY and WORLD
in SmoThreadIds.
This commit is contained in:
2026-02-18 02:05:44 -04:00
parent 687bab53b5
commit ab399cafeb
2 changed files with 17 additions and 15 deletions
+9 -3
View File
@@ -1,14 +1,16 @@
#ifndef SMO_COMPONENT_THREAD_H #ifndef SMO_COMPONENT_THREAD_H
#define SMO_COMPONENT_THREAD_H #define SMO_COMPONENT_THREAD_H
#include <config.h>
#include <string> #include <string>
// Include the spinscale componentThread.h which provides ComponentThread, PuppetThread, etc. // Include the spinscale componentThread.h which provides ComponentThread, PuppetThread, etc.
#include <spinscale/componentThread.h> #include <spinscale/componentThread.h>
namespace smo { namespace smo {
// Application-specific thread ID enum /* Application-specific thread ID enum
// Using regular enum (not enum class) to allow implicit conversion to ThreadId * Using regular enum (not enum class) to allow implicit conversion to ThreadId
*/
enum SmoThreadId : sscl::ThreadId enum SmoThreadId : sscl::ThreadId
{ {
MRNTT = 0, MRNTT = 0,
@@ -16,7 +18,11 @@ enum SmoThreadId : sscl::ThreadId
SIMULATOR, SIMULATOR,
SUBCONSCIOUS, SUBCONSCIOUS,
BODY, BODY,
WORLD, WORLD
#ifdef CONFIG_WORLD_USE_BODY_THREAD
= BODY
#endif
,
N_ITEMS N_ITEMS
}; };
+8 -12
View File
@@ -1,3 +1,4 @@
#include <config.h>
#include <iostream> #include <iostream>
#include <opts.h> #include <opts.h>
#include <spinscale/asynchronousContinuation.h> #include <spinscale/asynchronousContinuation.h>
@@ -23,18 +24,13 @@ Mind::Mind(void)
#ifndef CONFIG_WORLD_USE_BODY_THREAD #ifndef CONFIG_WORLD_USE_BODY_THREAD
, std::make_shared<MindThread>(SmoThreadId::WORLD, *this) , std::make_shared<MindThread>(SmoThreadId::WORLD, *this)
#endif #endif
}), }
director(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[0])), ),
canvas(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[1])), director(*this, componentThreads[SmoThreadId::DIRECTOR - 1]),
subconscious(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[2])), canvas(*this, componentThreads[SmoThreadId::SIMULATOR - 1]),
body(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[3])), subconscious(*this, componentThreads[SmoThreadId::SUBCONSCIOUS - 1]),
world(*this, body(*this, componentThreads[SmoThreadId::BODY - 1]),
#ifndef CONFIG_WORLD_USE_BODY_THREAD world(*this, componentThreads[SmoThreadId::WORLD - 1])
std::static_pointer_cast<sscl::ComponentThread>(componentThreads[4])
#else
std::static_pointer_cast<sscl::ComponentThread>(componentThreads[3])
#endif
)
{ {
} }