Async: new hierachy; manages reply posting and unlocking
Async: Use new [Non]PostedAsyncCont and callOriginalCb This new hierarchy of classes gives us a central mechanism for managing both reply-posting and lockSpec unlocking. * callOriginalCb: Now uses a modern C++ variadic template design enabling it to handle both direct calling and std::bind() re-binding of an arbitrary number of arguments from the caller. This enables us to mostly eliminate the repeated, bespoke definitions of callOriginalCb littered throughout the codebase. We've also propagated these changes throughout the codebase in this patch.
This commit is contained in:
@@ -72,7 +72,8 @@ std::optional<std::shared_ptr<Device>> DeviceManager::getDevice(
|
||||
|
||||
// GetOrCreateDeviceReq nested class implementation
|
||||
class DeviceManager::GetOrCreateDeviceReq
|
||||
: public smo::AsynchronousContinuation<livoxProto1_getOrCreateDeviceReqCbFn>
|
||||
: public smo::NonPostedAsynchronousContinuation<
|
||||
livoxProto1_getOrCreateDeviceReqCbFn>
|
||||
{
|
||||
public:
|
||||
DeviceManager& deviceManager;
|
||||
@@ -84,14 +85,14 @@ public:
|
||||
DeviceManager& mgr,
|
||||
std::shared_ptr<Device> device,
|
||||
livoxProto1_getOrCreateDeviceReqCbFn cb)
|
||||
: smo::AsynchronousContinuation<
|
||||
: smo::NonPostedAsynchronousContinuation<
|
||||
livoxProto1_getOrCreateDeviceReqCbFn>(std::move(cb)),
|
||||
deviceManager(mgr), pendingDevice(device)
|
||||
{}
|
||||
|
||||
// Public accessor for the original callback
|
||||
void callOriginalCallback(bool success, std::shared_ptr<Device> device)
|
||||
{ originalCbFn(success, device); }
|
||||
{ callOriginalCb(success, device); }
|
||||
|
||||
void callOriginalCallbackWithFailure()
|
||||
{ callOriginalCallback(false, nullptr); }
|
||||
@@ -176,7 +177,8 @@ void DeviceManager::getOrCreateDeviceReq(
|
||||
}
|
||||
|
||||
class DeviceManager::DestroyDeviceReq
|
||||
: public smo::AsynchronousContinuation<livoxProto1_destroyDeviceReqCbFn>
|
||||
: public smo::NonPostedAsynchronousContinuation<
|
||||
livoxProto1_destroyDeviceReqCbFn>
|
||||
{
|
||||
public:
|
||||
DeviceManager& deviceManager;
|
||||
@@ -187,14 +189,14 @@ public:
|
||||
DeviceManager& mgr,
|
||||
std::shared_ptr<Device> device,
|
||||
livoxProto1_destroyDeviceReqCbFn cb)
|
||||
: smo::AsynchronousContinuation<
|
||||
: smo::NonPostedAsynchronousContinuation<
|
||||
livoxProto1_destroyDeviceReqCbFn>(std::move(cb)),
|
||||
deviceManager(mgr), pendingDevice(device)
|
||||
{}
|
||||
|
||||
// Public accessor for the original callback
|
||||
void callOriginalCallback(bool success)
|
||||
{ originalCbFn(success); }
|
||||
{ callOriginalCb(success); }
|
||||
|
||||
void callOriginalCallbackWithFailure()
|
||||
{ callOriginalCallback(false); }
|
||||
|
||||
Reference in New Issue
Block a user