From d1e4c1a2eab4e6d80745ede86448af435116924f Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Mon, 15 Sep 2025 08:30:17 -0400 Subject: [PATCH] Body:finalize: Will run if even one initReq step was executed If even one step in Body.initializeReq was executed at all, then whether or not it succeeded, we consider the body component to have been initialized, at least with respect to whether finalizeReq ought to run. --- smocore/body/body.cpp | 15 +++++++++++++++ smocore/include/mind.h | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/smocore/body/body.cpp b/smocore/body/body.cpp index 9422fc5..6e8462d 100644 --- a/smocore/body/body.cpp +++ b/smocore/body/body.cpp @@ -65,6 +65,13 @@ public: sense_api::SenseApiManager::getInstance() .loadAllSenseApiLibsFromOptions(caller); + /** EXPLANATION: + * Consider body::initializeReq to have been called if even one of its + * operations was executed at all, whether successfully or + * unsuccessfully. + */ + context->parent.bodyComponentInitialized = true; + std::cout << sense_api::SenseApiManager::getInstance().stringifyLibs() << std::endl; @@ -171,6 +178,14 @@ void Body::finalizeReq(bodyLifetimeMgmtOpCbFn callback) + ": Must be invoked by Mrntt thread"); } + if (!parent.bodyComponentInitialized) + { + std::cout << "Mrntt: Body component not initialized. " + << "Skipping finalization." << "\n"; + callback(true); + return; + } + auto request = std::make_shared( parent, mrntt, callback); diff --git a/smocore/include/mind.h b/smocore/include/mind.h index a865c6e..14c7f4f 100644 --- a/smocore/include/mind.h +++ b/smocore/include/mind.h @@ -77,7 +77,8 @@ private: * This flag ensures that JOLTing happens exactly once and provides * a synchronization point for the entire system initialization. */ - bool threadsHaveBeenJolted = false; + bool threadsHaveBeenJolted = false, + bodyComponentInitialized = false; private: class MindLifetimeMgmtOp;