mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-23 19:48:32 +00:00
CompThr: make new changes compile
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <coroutine>
|
||||||
#include <spinscale/cps/callback.h>
|
#include <spinscale/cps/callback.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -160,20 +161,25 @@ public:
|
|||||||
|
|
||||||
void initializeTls(void);
|
void initializeTls(void);
|
||||||
|
|
||||||
|
typedef std::function<void()> threadLifetimeMgmtOpCbFn;
|
||||||
|
|
||||||
struct ViralThreadLifetimeMgmtInvoker
|
struct ViralThreadLifetimeMgmtInvoker
|
||||||
{
|
{
|
||||||
ViralThreadLifetimeMgmtInvoker(
|
ViralThreadLifetimeMgmtInvoker(
|
||||||
ThreadOp _threadOp
|
ThreadOp _threadOp,
|
||||||
PuppetThread &_parentThread,
|
PuppetThread &_parentThread,
|
||||||
const std::shared_ptr<PuppetThread> &_selfPtr = nullptr)
|
const std::shared_ptr<PuppetThread> &_selfPtr = nullptr)
|
||||||
: threadOp(_threadOp), parentThread(_parentThread), selfPtr(_selfPtr)
|
: threadOp(_threadOp), parentThread(_parentThread), selfPtr(_selfPtr)
|
||||||
{
|
{
|
||||||
cps::Callback<threadLifetimeMgmtOpCbFn> callback = [this]
|
cps::Callback<threadLifetimeMgmtOpCbFn> callback{
|
||||||
{
|
nullptr,
|
||||||
settled = true;
|
[this]()
|
||||||
if (callerSchedHandle)
|
{
|
||||||
{ callerSchedHandle.resume(); }
|
settled = true;
|
||||||
};
|
if (callerSchedHandle) {
|
||||||
|
callerSchedHandle.resume();
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
if (threadOp == ThreadOp::JOLT && selfPtr == nullptr)
|
if (threadOp == ThreadOp::JOLT && selfPtr == nullptr)
|
||||||
{
|
{
|
||||||
@@ -208,7 +214,7 @@ public:
|
|||||||
bool await_ready() const noexcept { return settled; }
|
bool await_ready() const noexcept { return settled; }
|
||||||
|
|
||||||
bool await_suspend(
|
bool await_suspend(
|
||||||
std::coroutine_handle<void> const _callerSchedHandle) noexcept
|
std::coroutine_handle<> _callerSchedHandle) noexcept
|
||||||
{
|
{
|
||||||
if (settled) { return false; }
|
if (settled) { return false; }
|
||||||
callerSchedHandle = _callerSchedHandle;
|
callerSchedHandle = _callerSchedHandle;
|
||||||
@@ -217,8 +223,9 @@ public:
|
|||||||
|
|
||||||
void await_resume() noexcept {}
|
void await_resume() noexcept {}
|
||||||
|
|
||||||
|
ThreadOp threadOp;
|
||||||
bool settled = false;
|
bool settled = false;
|
||||||
std::coroutine_handle<void> callerSchedHandle;
|
std::coroutine_handle<> callerSchedHandle;
|
||||||
PuppetThread &parentThread;
|
PuppetThread &parentThread;
|
||||||
const std::shared_ptr<PuppetThread> selfPtr;
|
const std::shared_ptr<PuppetThread> selfPtr;
|
||||||
};
|
};
|
||||||
@@ -232,8 +239,6 @@ public:
|
|||||||
ViralThreadLifetimeMgmtInvoker exitThreadAReq()
|
ViralThreadLifetimeMgmtInvoker exitThreadAReq()
|
||||||
{ return ViralThreadLifetimeMgmtInvoker(ThreadOp::EXIT, *this); }
|
{ return ViralThreadLifetimeMgmtInvoker(ThreadOp::EXIT, *this); }
|
||||||
|
|
||||||
// Thread management methods
|
|
||||||
typedef std::function<void()> threadLifetimeMgmtOpCbFn;
|
|
||||||
void startThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
void startThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
||||||
void exitThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
void exitThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
||||||
void pauseThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
void pauseThreadReq(cps::Callback<threadLifetimeMgmtOpCbFn> callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user