Mrntt: Call initializeDeviceReattacher in init

It works surprisingly well on the first try.
This commit is contained in:
2025-09-29 01:07:32 -04:00
parent 6cebf6856e
commit cea65dcd00
3 changed files with 34 additions and 2 deletions
+20
View File
@@ -10,6 +10,7 @@
#include <callback.h>
#include <componentThread.h>
#include <deviceManager/deviceManager.h>
#include <deviceManager/deviceReattacher.h>
#include <senseApis/senseApiManager.h>
#include <marionette/marionette.h>
#include <mind.h>
@@ -26,6 +27,10 @@ std::vector<std::shared_ptr<DeviceRole>>
std::vector<DeviceAttachmentSpec>
DeviceManager::commandLineDASpecs;
DeviceManager::~DeviceManager()
{
}
const std::string DeviceManager::stringifyDeviceSpecs(void)
{
std::ostringstream oss;
@@ -700,5 +705,20 @@ void DeviceManager::detachAllAttachedDeviceRoles(
request.get(), request));
}
void DeviceManager::initializeDeviceReattacher()
{
deviceReattacher = std::make_unique<DeviceReattacher>(
*this, mrntt::mrntt.thread);
deviceReattacher->start();
}
void DeviceManager::finalizeDeviceReattacher()
{
if (deviceReattacher) {
deviceReattacher->stop();
}
}
} // namespace device
} // namespace smo
+10 -2
View File
@@ -13,12 +13,15 @@
#include <asynchronousLoop.h>
#include <deviceManager/device.h>
#include <deviceManager/deviceRole.h>
#include <deviceManager/deviceReattacher.h>
#include <callback.h>
#include <qutex.h>
namespace smo {
namespace device {
class DeviceReattacher;
class DeviceManager
{
public:
@@ -33,6 +36,9 @@ public:
void finalize(void)
{};
void initializeDeviceReattacher();
void finalizeDeviceReattacher();
std::string readDapSpecFile(const std::string& filename);
void collateAllDapSpecs(void);
void parseAllDapSpecs(void);
@@ -82,9 +88,9 @@ public:
private:
DeviceManager()
: qutex("DeviceManager")
: qutex("DeviceManager"), deviceReattacher(nullptr)
{}
~DeviceManager() = default;
~DeviceManager();
DeviceManager(const DeviceManager&) = delete;
DeviceManager& operator=(const DeviceManager&) = delete;
@@ -98,6 +104,8 @@ public:
static std::vector<DeviceAttachmentSpec> commandLineDASpecs;
private:
std::unique_ptr<DeviceReattacher> deviceReattacher;
class NewDeviceAttachmentSpecInd;
class RemoveDeviceAttachmentSpecReq;
class AttachSenseDeviceReq;
+4
View File
@@ -4,6 +4,7 @@
#include <callback.h>
#include <component.h>
#include <componentThread.h>
#include <deviceManager/deviceManager.h>
#include <mindManager/mindManager.h>
#include <marionette/marionette.h>
@@ -56,6 +57,7 @@ public:
return;
}
device::DeviceManager::getInstance().initializeDeviceReattacher();
context->callOriginalCb(success);
}
@@ -70,6 +72,8 @@ public:
+ ": Must be executed on Marionette thread");
}
device::DeviceManager::getInstance().finalizeDeviceReattacher();
smo::mind::globalMind->finalizeReq({context, std::bind(
&MrnttLifetimeMgmtOp::finalizeReq2,
this, context, std::placeholders::_1)});