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:
+9
-23
@@ -84,24 +84,17 @@ Mind::getMindThreads() const
|
||||
}
|
||||
|
||||
class Mind::MindLifetimeMgmtOp
|
||||
: public TargetedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>
|
||||
: public PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>
|
||||
{
|
||||
public:
|
||||
MindLifetimeMgmtOp(
|
||||
Mind &parent, const std::shared_ptr<ComponentThread> &caller,
|
||||
mindLifetimeMgmtOpCbFn callback)
|
||||
: TargetedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>(
|
||||
: PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>(
|
||||
caller, callback),
|
||||
parent(parent)
|
||||
{}
|
||||
|
||||
void callOriginalCbFn(bool success)
|
||||
{
|
||||
if (originalCbFn) {
|
||||
caller->getIoService().post(std::bind(originalCbFn, success));
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
Mind &parent;
|
||||
|
||||
@@ -147,7 +140,7 @@ public:
|
||||
)
|
||||
{
|
||||
std::cout << "Mrntt: Body component initialized." << "\n";
|
||||
callOriginalCbFn(success);
|
||||
callOriginalCb(success);
|
||||
}
|
||||
|
||||
void finalizeReq1_posted(
|
||||
@@ -198,7 +191,7 @@ public:
|
||||
)
|
||||
{
|
||||
std::cout << "Mrntt: All mind threads exited." << "\n";
|
||||
callOriginalCbFn(true);
|
||||
callOriginalCb(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -260,24 +253,17 @@ void Mind::distributeAndPinThreadsAcrossCpus()
|
||||
}
|
||||
|
||||
class Mind::MindThreadLifetimeMgmtOp
|
||||
: public AsynchronousContinuation<mindThreadLifetimeMgmtOpCbFn>
|
||||
: public NonPostedAsynchronousContinuation<mindThreadLifetimeMgmtOpCbFn>
|
||||
{
|
||||
public:
|
||||
MindThreadLifetimeMgmtOp(
|
||||
Mind &parent,unsigned int nThreads,
|
||||
mindThreadLifetimeMgmtOpCbFn callback)
|
||||
: AsynchronousContinuation<mindThreadLifetimeMgmtOpCbFn>(callback),
|
||||
: NonPostedAsynchronousContinuation<mindThreadLifetimeMgmtOpCbFn>(callback),
|
||||
loop(nThreads),
|
||||
parent(parent)
|
||||
{}
|
||||
|
||||
void callOriginalCbFn(void)
|
||||
{
|
||||
if (originalCbFn) {
|
||||
originalCbFn();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
AsynchronousLoop loop;
|
||||
Mind &parent;
|
||||
@@ -293,7 +279,7 @@ public:
|
||||
}
|
||||
|
||||
parent.threadsHaveBeenJolted = true;
|
||||
callOriginalCbFn();
|
||||
callOriginalCb();
|
||||
}
|
||||
|
||||
void executeGenericOpOnAllMindThreadsReq1(
|
||||
@@ -305,7 +291,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
callOriginalCbFn();
|
||||
callOriginalCb();
|
||||
}
|
||||
|
||||
void exitAllMindThreadsReq1(
|
||||
@@ -321,7 +307,7 @@ public:
|
||||
thread->thread.join();
|
||||
}
|
||||
|
||||
callOriginalCbFn();
|
||||
callOriginalCb();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user