DevMgr:at/detachSenseDevReq: acquire Api lib Qutex

This commit is contained in:
2025-09-30 18:12:20 -04:00
parent b0d61c3e38
commit e600b0f96e
2 changed files with 45 additions and 4 deletions
+43 -4
View File
@@ -323,9 +323,10 @@ public:
AttachSenseDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec,
const std::shared_ptr<ComponentThread> &caller,
Callback<attachSenseDeviceReqCbFn> cb)
Callback<attachSenseDeviceReqCbFn> cb,
std::vector<std::reference_wrapper<Qutex>> requiredLocks)
: SerializedAsynchronousContinuation<attachSenseDeviceReqCbFn>(
caller, cb, {std::ref(DeviceManager::getInstance().qutex)}),
caller, cb, requiredLocks),
spec(spec)
{}
@@ -467,8 +468,27 @@ void DeviceManager::attachSenseDeviceReq(
)
{
const auto& caller = ComponentThread::getSelf();
// Get the sense API lib's qutex
auto libOpt = sense_api::SenseApiManager::getInstance()
.getSenseApiLibByApiName(spec->api);
if (!libOpt)
{
std::cerr << "attachSenseDeviceReq: No library found for API '"
<< spec->api << "'" << std::endl;
cb.callbackFn(false, spec);
return;
}
auto& lib = *libOpt.value();
auto request = std::make_shared<AttachSenseDeviceReq>(
spec, caller, cb);
spec, caller, cb,
LockSet<attachSenseDeviceReqCbFn>::Set{
std::ref(DeviceManager::getInstance().qutex),
std::ref(lib.qutex)
});
AttachSenseDeviceReq::LockerAndInvoker lockvoker(
*request, mrntt::mrntt.thread,
@@ -483,8 +503,27 @@ void DeviceManager::detachSenseDeviceReq(
)
{
const auto& caller = ComponentThread::getSelf();
// Get the sense API lib's qutex
auto libOpt = sense_api::SenseApiManager::getInstance()
.getSenseApiLibByApiName(spec->api);
if (!libOpt)
{
std::cerr << "detachSenseDeviceReq: No library found for API '"
<< spec->api << "'" << std::endl;
cb.callbackFn(false, spec);
return;
}
auto& lib = *libOpt.value();
auto request = std::make_shared<DetachSenseDeviceReq>(
spec, caller, cb);
spec, caller, cb,
LockSet<detachSenseDeviceReqCbFn>::Set{
std::ref(DeviceManager::getInstance().qutex),
std::ref(lib.qutex)
});
DetachSenseDeviceReq::LockerAndInvoker lockvoker(
*request, mrntt::mrntt.thread,