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;