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:
@@ -10,27 +10,17 @@ namespace smo {
|
||||
namespace mrntt {
|
||||
|
||||
class MarionetteComponent::MrnttLifetimeMgmtOp
|
||||
: public AsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>,
|
||||
public ContinuationTarget
|
||||
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
|
||||
{
|
||||
public:
|
||||
MrnttLifetimeMgmtOp(
|
||||
MarionetteComponent &parent, const std::shared_ptr<ComponentThread> &caller,
|
||||
mrnttLifetimeMgmtOpCbFn callback)
|
||||
: AsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(callback),
|
||||
ContinuationTarget(caller),
|
||||
parent(parent)
|
||||
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
|
||||
caller, callback),
|
||||
parent(parent)
|
||||
{}
|
||||
|
||||
void callOriginalCbFn(bool success)
|
||||
{
|
||||
if (originalCbFn)
|
||||
{
|
||||
caller->getIoService().post(
|
||||
std::bind(originalCbFn, success));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
MarionetteComponent &parent;
|
||||
|
||||
@@ -62,11 +52,11 @@ public:
|
||||
{
|
||||
std::cerr << __func__ << ": Failed to initialize globalMind"
|
||||
<< std::endl;
|
||||
context->callOriginalCbFn(false);
|
||||
context->callOriginalCb(false);
|
||||
return;
|
||||
}
|
||||
|
||||
context->callOriginalCbFn(success);
|
||||
context->callOriginalCb(success);
|
||||
}
|
||||
|
||||
void finalizeReq1_posted(
|
||||
@@ -95,11 +85,11 @@ public:
|
||||
{
|
||||
std::cerr << __func__ << ": globalMind finalization failed"
|
||||
<< std::endl;
|
||||
context->callOriginalCbFn(false);
|
||||
context->callOriginalCb(false);
|
||||
return;
|
||||
}
|
||||
|
||||
context->callOriginalCbFn(success);
|
||||
context->callOriginalCb(success);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user