diff --git a/include/spinscale/componentThread.h b/include/spinscale/componentThread.h index 5207c82..9ac8bea 100644 --- a/include/spinscale/componentThread.h +++ b/include/spinscale/componentThread.h @@ -169,18 +169,19 @@ public: ThreadOp _threadOp, PuppetThread &_parentThread, const std::shared_ptr &_selfPtr = nullptr) - : threadOp(_threadOp), parentThread(_parentThread), selfPtr(_selfPtr) + : threadOp(_threadOp), + parentThread(_parentThread), + selfPtr(_selfPtr), + lifetimeMgmtCallback{ + nullptr, + [this]() + { + settled = true; + if (callerSchedHandle) { + callerSchedHandle.resume(); + } + }} { - cps::Callback callback{ - nullptr, - [this]() - { - settled = true; - if (callerSchedHandle) { - callerSchedHandle.resume(); - } - }}; - if (threadOp == ThreadOp::JOLT && selfPtr == nullptr) { throw std::runtime_error(std::string(__func__) @@ -190,19 +191,19 @@ public: switch (threadOp) { case ThreadOp::START: - parentThread.startThreadReq(callback); + parentThread.startThreadReq(lifetimeMgmtCallback); break; case ThreadOp::PAUSE: - parentThread.pauseThreadReq(callback); + parentThread.pauseThreadReq(lifetimeMgmtCallback); break; case ThreadOp::RESUME: - parentThread.resumeThreadReq(callback); + parentThread.resumeThreadReq(lifetimeMgmtCallback); break; case ThreadOp::EXIT: - parentThread.exitThreadReq(callback); + parentThread.exitThreadReq(lifetimeMgmtCallback); break; case ThreadOp::JOLT: - parentThread.joltThreadReq(selfPtr, callback); + parentThread.joltThreadReq(selfPtr, lifetimeMgmtCallback); break; default: @@ -228,6 +229,7 @@ public: std::coroutine_handle<> callerSchedHandle; PuppetThread &parentThread; const std::shared_ptr selfPtr; + cps::Callback lifetimeMgmtCallback; }; ViralThreadLifetimeMgmtInvoker startThreadAReq() diff --git a/include/spinscale/puppetApplication.h b/include/spinscale/puppetApplication.h index 1644e8a..fbd7956 100644 --- a/include/spinscale/puppetApplication.h +++ b/include/spinscale/puppetApplication.h @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace sscl { @@ -20,15 +21,15 @@ public: // Thread management methods typedef std::function puppetThreadLifetimeMgmtOpCbFn; - void joltAllPuppetThreadsCReq( + NonViralNonPostingInvoker joltAllPuppetThreadsCReq( cps::Callback callback); - void startAllPuppetThreadsCReq( + NonViralNonPostingInvoker startAllPuppetThreadsCReq( cps::Callback callback); - void pauseAllPuppetThreadsCReq( + NonViralNonPostingInvoker pauseAllPuppetThreadsCReq( cps::Callback callback); - void resumeAllPuppetThreadsCReq( + NonViralNonPostingInvoker resumeAllPuppetThreadsCReq( cps::Callback callback); - void exitAllPuppetThreadsCReq( + NonViralNonPostingInvoker exitAllPuppetThreadsCReq( cps::Callback callback); // CPU distribution method