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:
+4
-15
@@ -16,27 +16,16 @@ Body::Body(Mind &parent, const std::shared_ptr<ComponentThread> &thread)
|
||||
}
|
||||
|
||||
class Body::InitializeReq
|
||||
: public AsynchronousContinuation<bodyLifetimeMgmtOpCbFn>,
|
||||
public ContinuationTarget
|
||||
: public PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>
|
||||
{
|
||||
public:
|
||||
InitializeReq(
|
||||
Mind &parent, const std::shared_ptr<ComponentThread> &caller,
|
||||
bodyLifetimeMgmtOpCbFn callback)
|
||||
: AsynchronousContinuation<bodyLifetimeMgmtOpCbFn>(callback),
|
||||
ContinuationTarget(caller),
|
||||
: PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>(caller, callback),
|
||||
parent(parent)
|
||||
{}
|
||||
|
||||
void callOriginalCbFn(bool success)
|
||||
{
|
||||
if (originalCbFn)
|
||||
{
|
||||
caller->getIoService().post(
|
||||
std::bind(originalCbFn, success));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Mind &parent;
|
||||
|
||||
@@ -104,7 +93,7 @@ public:
|
||||
<< results.nSucceeded << " of " << results.nTotal
|
||||
<< " sense devices." << "\n";
|
||||
|
||||
callOriginalCbFn(results.nSucceeded > 0);
|
||||
callOriginalCb(results.nSucceeded > 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -148,7 +137,7 @@ public:
|
||||
|
||||
std::cout << "Mrntt: About to unload all sense api libs." << "\n";
|
||||
sense_api::SenseApiManager::getInstance().unloadAllSenseApiLibs();
|
||||
callOriginalCbFn(results.nSucceeded == results.nTotal);
|
||||
callOriginalCb(results.nSucceeded == results.nTotal);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user