Async: add TargetedContinuation

This class enables us to consistently represent continuations
that are intended to be posted on a particular target handling
thread. It hols a sh_ptr to the caller so that the target thread
can re-enqueue the response on the caller after processing the
REQ/IND op.
This commit is contained in:
2025-09-11 18:37:48 -04:00
parent f5195450e4
commit b8c931397d
3 changed files with 51 additions and 13 deletions
+14 -8
View File
@@ -120,7 +120,7 @@ Device::~Device()
* This class manages the overall device connection process including handshake and heartbeat setup
*/
class Device::ConnectReq
: public AsynchronousContinuation<Device::connectReqCbFn>
: public smo::AsynchronousContinuation<Device::connectReqCbFn>
{
private:
Device& device;
@@ -128,7 +128,9 @@ private:
public:
ConnectReq(Device& dev, Device::connectReqCbFn cb)
: AsynchronousContinuation(std::move(cb)), device(dev) {}
: smo::AsynchronousContinuation<Device::connectReqCbFn>(
std::move(cb)), device(dev)
{}
/** FIXME:
* WE need to assign the ipAddr to the Device being connected up.
@@ -259,7 +261,7 @@ void Device::connectReq(Device::connectReqCbFn callback)
}
class Device::ConnectToKnownDeviceReq
: public AsynchronousContinuation<Device::connectToKnownDeviceReqCbFn>
: public smo::AsynchronousContinuation<Device::connectToKnownDeviceReqCbFn>
{
public:
Device& device;
@@ -267,7 +269,8 @@ public:
std::shared_ptr<livoxProto1::comms::DiscoveredDevice> deviceInfo;
ConnectToKnownDeviceReq(Device& dev, Device::connectToKnownDeviceReqCbFn cb)
: AsynchronousContinuation(std::move(cb)), device(dev)
: smo::AsynchronousContinuation<Device::connectToKnownDeviceReqCbFn>(
std::move(cb)), device(dev)
{}
// Public accessor for the original callback
@@ -360,7 +363,8 @@ void Device::connectToKnownDeviceReq(
}
class Device::ConnectByDeviceIdentifierReq
: public AsynchronousContinuation<Device::connectByDeviceIdentifierReqCbFn>
: public smo::AsynchronousContinuation<
Device::connectByDeviceIdentifierReqCbFn>
{
public:
Device& device;
@@ -368,7 +372,8 @@ public:
ConnectByDeviceIdentifierReq(
Device& dev, Device::connectByDeviceIdentifierReqCbFn cb)
: AsynchronousContinuation(std::move(cb)), device(dev)
: smo::AsynchronousContinuation<Device::connectByDeviceIdentifierReqCbFn>(
std::move(cb)), device(dev)
{}
// Public accessor for the original callback
@@ -440,7 +445,7 @@ void Device::connectByDeviceIdentifierReq(
}
class Device::ExecuteHandshakeReq
: public AsynchronousContinuation<Device::executeHandshakeReqCbFn>
: public smo::AsynchronousContinuation<Device::executeHandshakeReqCbFn>
{
public:
friend void Device::executeHandshakeReq(
@@ -477,7 +482,8 @@ public:
ExecuteHandshakeReq(
Device& dev, const std::string& deviceIP,
Device::executeHandshakeReqCbFn cb)
: AsynchronousContinuation(std::move(cb)),
: smo::AsynchronousContinuation<Device::executeHandshakeReqCbFn>(
std::move(cb)),
device(dev), deviceIP(deviceIP),
handshakeFdDesc(device.componentThread->getIoService()),
timeoutTimer(device.componentThread->getIoService())