Use DynamicViralPostingInvoker in at/detachStimBuffDeviceCReq

This commit is contained in:
2026-05-31 07:13:53 -04:00
parent c2eea37a7b
commit d1c74a027c
6 changed files with 62 additions and 25 deletions
+27 -11
View File
@@ -14,6 +14,7 @@
#include <marionette/marionette.h>
#include <marionette/marionetteThread.h>
#include <mind.h>
#include <spinscale/co/postTarget.h>
#include <spinscale/co/group.h>
namespace smo {
@@ -32,6 +33,16 @@ void assertMarionetteThread()
}
}
std::shared_ptr<sscl::ComponentThread> threadForDeviceOp(
const DeviceAttachmentSpec& spec)
{
if (spec.sensorType == 'e') {
return mind::globalMind->world.thread;
}
return mind::globalMind->body.thread;
}
} // namespace
DeviceManager::~DeviceManager()
@@ -87,29 +98,30 @@ DeviceManager::attachStimBuffDeviceCReq(
co_await lib.s.lock.getAcquireInvocationAndSuspensionPolicy();
sbamGuard.release();
/** EXPLANATION:
* We pass in either the body or world thread here, depending on whether
* the device is an introspector (idev) or extrospector (edev).
*
* Introspectors are attached to the body thread; extrospectors are
* attached to the world thread.
*/
std::shared_ptr<sscl::ComponentThread> threadForAttachment;
/** EXPLANATION:
* We pass in either the body or world thread here, depending on whether
* the device is an introspector (idev) or extrospector (edev).
*
* Introspectors are attached to the body thread; extrospectors are
* attached to the world thread.
*/
std::shared_ptr<sscl::ComponentThread> targetThread =
threadForDeviceOp(*spec);
if (spec->sensorType == 'e')
{
threadForAttachment = mind::globalMind->world.thread;
std::cout << __func__ << ": Attaching edev "
<< spec->deviceIdentifier << " to world thread" << "\n";
}
else
{
threadForAttachment = mind::globalMind->body.thread;
std::cout << __func__ << ": Attaching non-edev "
<< spec->deviceIdentifier << " to body thread" << "\n";
}
co_return co_await lib.stimBuffApiDesc.sal_mgmt_libOps.attachDeviceCReq(
spec, threadForAttachment);
sscl::co::ExplicitPostTarget{targetThread->getIoContext()},
spec, targetThread);
}
mrntt::MrnttViralPostingInvoker<stim_buff::StimBuffDeviceOpResult>
@@ -150,7 +162,11 @@ DeviceManager::detachStimBuffDeviceCReq(
co_await lib.s.lock.getAcquireInvocationAndSuspensionPolicy();
sbamGuard.release();
std::shared_ptr<sscl::ComponentThread> targetThread =
threadForDeviceOp(*spec);
co_return co_await lib.stimBuffApiDesc.sal_mgmt_libOps.detachDeviceCReq(
sscl::co::ExplicitPostTarget{targetThread->getIoContext()},
spec);
}