mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-02-27 14:36:04 +00:00
Rename mrntt=>pptr
We'll probably use the name "marionette" as an application-level name.
This commit is contained in:
@@ -34,9 +34,9 @@ public:
|
|||||||
{ break; }
|
{ break; }
|
||||||
|
|
||||||
/** EXPLANATION:
|
/** EXPLANATION:
|
||||||
* In the mrntt and mind thread loops we call checkException() after
|
* In the puppeteer and mind thread loops we call checkException()
|
||||||
* run() returns, but we don't have to do that here because
|
* after run() returns, but we don't have to do that here because
|
||||||
* setException() calls stop.
|
* setException() calls stop().
|
||||||
*
|
*
|
||||||
* So if an exception is set on our thread, we'll break out of this
|
* So if an exception is set on our thread, we'll break out of this
|
||||||
* loop due to the check for stopped() above, and that'll take us
|
* loop due to the check for stopped() above, and that'll take us
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
namespace sscl {
|
namespace sscl {
|
||||||
|
|
||||||
class MarionetteThread;
|
class PuppeteerThread;
|
||||||
class PuppetThread;
|
class PuppetThread;
|
||||||
|
|
||||||
// ThreadId is a generic type - application-specific enums should be defined elsewhere
|
// ThreadId is a generic type - application-specific enums should be defined elsewhere
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
static const std::shared_ptr<ComponentThread> getSelf(void);
|
static const std::shared_ptr<ComponentThread> getSelf(void);
|
||||||
static bool tlsInitialized(void);
|
static bool tlsInitialized(void);
|
||||||
static std::shared_ptr<MarionetteThread> getMrntt();
|
static std::shared_ptr<PuppeteerThread> getMrntt();
|
||||||
|
|
||||||
typedef void (mainFn)(ComponentThread &self);
|
typedef void (mainFn)(ComponentThread &self);
|
||||||
|
|
||||||
@@ -66,18 +66,18 @@ public:
|
|||||||
std::atomic<bool> keepLooping;
|
std::atomic<bool> keepLooping;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MarionetteThread
|
class PuppeteerThread
|
||||||
: public std::enable_shared_from_this<MarionetteThread>,
|
: public std::enable_shared_from_this<PuppeteerThread>,
|
||||||
public ComponentThread
|
public ComponentThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarionetteThread(ThreadId id = 0)
|
PuppeteerThread(ThreadId id = 0)
|
||||||
: ComponentThread(id),
|
: ComponentThread(id),
|
||||||
thread(main, std::ref(*this))
|
thread(main, std::ref(*this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main(MarionetteThread& self);
|
static void main(PuppeteerThread& self);
|
||||||
void initializeTls(void);
|
void initializeTls(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -154,14 +154,15 @@ public:
|
|||||||
class ThreadLifetimeMgmtOp;
|
class ThreadLifetimeMgmtOp;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace mrntt {
|
namespace pptr {
|
||||||
extern std::shared_ptr<MarionetteThread> thread;
|
extern std::shared_ptr<PuppeteerThread> thread;
|
||||||
|
|
||||||
// Forward declaration for marionette thread ID management
|
// Forward declaration for puppeteer thread ID management
|
||||||
// Must be after sscl namespace so ThreadId is defined
|
// Must be after sscl namespace so ThreadId is defined
|
||||||
extern ThreadId marionetteThreadId;
|
extern ThreadId puppeteerThreadId;
|
||||||
void setMarionetteThreadId(ThreadId id);
|
void setPuppeteerThreadId(ThreadId id);
|
||||||
} // namespace mrntt
|
} // namespace pptr
|
||||||
}
|
|
||||||
|
} // namespace sscl
|
||||||
|
|
||||||
#endif // COMPONENT_THREAD_H
|
#endif // COMPONENT_THREAD_H
|
||||||
|
|||||||
@@ -8,9 +8,10 @@
|
|||||||
|
|
||||||
namespace sscl {
|
namespace sscl {
|
||||||
|
|
||||||
class MarionetteThread;
|
class PuppeteerThread;
|
||||||
|
extern std::shared_ptr<sscl::PuppeteerThread> thread;
|
||||||
|
|
||||||
namespace mrntt {
|
namespace pptr {
|
||||||
|
|
||||||
class MarionetteComponent
|
class MarionetteComponent
|
||||||
: public sscl::Component
|
: public sscl::Component
|
||||||
@@ -31,14 +32,12 @@ private:
|
|||||||
class TerminationEvent;
|
class TerminationEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::shared_ptr<sscl::MarionetteThread> thread;
|
|
||||||
|
|
||||||
extern std::atomic<int> exitCode;
|
extern std::atomic<int> exitCode;
|
||||||
void exitMarionetteLoop();
|
void exitMarionetteLoop();
|
||||||
void marionetteFinalizeReqCb(bool success);
|
void marionetteFinalizeReqCb(bool success);
|
||||||
extern MarionetteComponent mrntt;
|
extern MarionetteComponent mrntt;
|
||||||
|
|
||||||
} // namespace mrntt
|
} // namespace pptr
|
||||||
|
|
||||||
struct CrtCommandLineArgs
|
struct CrtCommandLineArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ parent(parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mrntt {
|
namespace pptr {
|
||||||
|
|
||||||
MarionetteComponent::MarionetteComponent(
|
MarionetteComponent::MarionetteComponent(
|
||||||
const std::shared_ptr<sscl::ComponentThread> &thread)
|
const std::shared_ptr<sscl::ComponentThread> &thread)
|
||||||
@@ -24,5 +24,6 @@ MarionetteComponent::MarionetteComponent(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mrntt
|
} // namespace pptr
|
||||||
|
|
||||||
} // namespace sscl
|
} // namespace sscl
|
||||||
|
|||||||
@@ -13,33 +13,33 @@
|
|||||||
|
|
||||||
namespace sscl {
|
namespace sscl {
|
||||||
|
|
||||||
namespace mrntt {
|
namespace pptr {
|
||||||
/* Global variable to store the marionette thread ID
|
/* Global variable to store the puppeteer thread ID
|
||||||
* Default value is 0, but should be set by application code via
|
* Default value is 0, but should be set by application code via
|
||||||
* setMarionetteThreadId().
|
* setPuppeteerThreadId().
|
||||||
*/
|
*/
|
||||||
ThreadId marionetteThreadId = 0;
|
ThreadId puppeteerThreadId = 0;
|
||||||
/* Global marionette thread instance - defined here but initialized by
|
/* Global puppeteer thread instance - defined here but initialized by
|
||||||
* application code.
|
* application code.
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<MarionetteThread> thread;
|
std::shared_ptr<PuppeteerThread> thread;
|
||||||
|
|
||||||
void setMarionetteThreadId(ThreadId id)
|
void setPuppeteerThreadId(ThreadId id)
|
||||||
{
|
{
|
||||||
marionetteThreadId = id;
|
puppeteerThreadId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mrntt
|
} // namespace pptr
|
||||||
|
|
||||||
thread_local std::shared_ptr<ComponentThread> thisComponentThread;
|
thread_local std::shared_ptr<ComponentThread> thisComponentThread;
|
||||||
|
|
||||||
// Implementation of static method
|
// Implementation of static method
|
||||||
std::shared_ptr<MarionetteThread> ComponentThread::getMrntt()
|
std::shared_ptr<PuppeteerThread> ComponentThread::getMrntt()
|
||||||
{
|
{
|
||||||
return sscl::mrntt::thread;
|
return sscl::pptr::thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarionetteThread::initializeTls(void)
|
void PuppeteerThread::initializeTls(void)
|
||||||
{
|
{
|
||||||
thisComponentThread = shared_from_this();
|
thisComponentThread = shared_from_this();
|
||||||
}
|
}
|
||||||
@@ -177,24 +177,24 @@ void PuppetThread::joltThreadReq(
|
|||||||
* We also can't use getSelf() as yet for the same reason: getSelf()
|
* We also can't use getSelf() as yet for the same reason: getSelf()
|
||||||
* requires TLS to be set up.
|
* requires TLS to be set up.
|
||||||
*
|
*
|
||||||
* To obtain a sh_ptr to the caller, we just supply the mrntt thread since
|
* To obtain a sh_ptr to the caller, we just supply the puppeteer thread
|
||||||
* JOLT is always invoked by the mrntt thread. The JOLT sequence that the
|
* since JOLT is always invoked by the puppeteer thread. The JOLT sequence
|
||||||
* CRT main() function invokes on the mrntt thread is special since it
|
* that the CRT main() function invokes on the puppeteer thread is special
|
||||||
* supplies cmdline args and envp.
|
* since it supplies cmdline args and envp.
|
||||||
*
|
*
|
||||||
* To obtain a sh_ptr to the target thread, we use the selfPtr parameter
|
* To obtain a sh_ptr to the target thread, we use the selfPtr parameter
|
||||||
* passed in by the caller.
|
* passed in by the caller.
|
||||||
*/
|
*/
|
||||||
if (id == sscl::mrntt::marionetteThreadId)
|
if (id == sscl::pptr::puppeteerThreadId)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(std::string(__func__)
|
throw std::runtime_error(std::string(__func__)
|
||||||
+ ": invoked on mrntt thread");
|
+ ": invoked on puppeteer thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MarionetteThread> mrntt = sscl::mrntt::thread;
|
std::shared_ptr<PuppeteerThread> puppeteer = sscl::pptr::thread;
|
||||||
|
|
||||||
auto request = std::make_shared<ThreadLifetimeMgmtOp>(
|
auto request = std::make_shared<ThreadLifetimeMgmtOp>(
|
||||||
mrntt, selfPtr, callback);
|
puppeteer, selfPtr, callback);
|
||||||
|
|
||||||
this->getIoService().post(
|
this->getIoService().post(
|
||||||
STC(std::bind(
|
STC(std::bind(
|
||||||
@@ -236,10 +236,10 @@ void PuppetThread::exitThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
|||||||
|
|
||||||
void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||||
{
|
{
|
||||||
if (id == sscl::mrntt::marionetteThreadId)
|
if (id == sscl::pptr::puppeteerThreadId)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(std::string(__func__)
|
throw std::runtime_error(std::string(__func__)
|
||||||
+ ": invoked on mrntt thread");
|
+ ": invoked on puppeteer thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ComponentThread> caller = getSelf();
|
std::shared_ptr<ComponentThread> caller = getSelf();
|
||||||
@@ -255,10 +255,10 @@ void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
|||||||
|
|
||||||
void PuppetThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
void PuppetThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||||
{
|
{
|
||||||
if (id == sscl::mrntt::marionetteThreadId)
|
if (id == sscl::pptr::puppeteerThreadId)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(std::string(__func__)
|
throw std::runtime_error(std::string(__func__)
|
||||||
+ ": invoked on mrntt thread");
|
+ ": invoked on puppeteer thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post to the pause_io_service to unblock the paused thread
|
// Post to the pause_io_service to unblock the paused thread
|
||||||
|
|||||||
Reference in New Issue
Block a user