Files
salmanoff/smocore/include/marionette/marionette.h
T
hayodea cde2737876 Libspinscale: Initial top-level SMO port to coroutine framework
We haven't ported everything. Just the top-level methods. We'll
dig in to the leaf stuff later. Surprisingly, this all went without
any real difficulties.

Runs like a charm on first try.
2026-05-24 23:26:18 -04:00

79 lines
1.9 KiB
C++

#ifndef _MARIONETTE_H
#define _MARIONETTE_H
#include <boost/asio/signal_set.hpp>
#include <cstdint>
#include <atomic>
#include <exception>
#include <functional>
#include <memory>
#include <optional>
#include <spinscale/component.h>
#include <marionette/marionetteThread.h>
namespace sscl {
class PuppeteerThread;
} // namespace sscl
namespace smo {
namespace mrntt {
class MarionetteComponent
: public sscl::pptr::PuppeteerComponent
{
public:
MarionetteComponent(const std::shared_ptr<sscl::PuppeteerThread> &thread)
: sscl::pptr::PuppeteerComponent(thread)
{}
~MarionetteComponent() = default;
void holdInitializeCReq(std::function<void()> completion);
void holdFinalizeCReq(std::function<void()> completion);
MrnttNonViralPostingInvoker initializeCReq(
std::exception_ptr &exceptionPtr,
std::function<void()> callback);
MrnttNonViralPostingInvoker finalizeCReq(
std::exception_ptr &exceptionPtr,
std::function<void()> callback);
void exceptionInd();
void handleLoopExceptionHook() override;
static void preJoltHook(sscl::PuppeteerThread &thr);
protected:
void postJoltHook() override;
void tryBlock1Hook() override;
void preLoopHook() override;
void postLoopHook() override;
void postTryBlock1CatchHook() override;
void handleTryBlock1TypedException(const std::exception& e) override;
void handleTryBlock1UnknownException() override;
private:
std::unique_ptr<boost::asio::signal_set> signals;
bool callShutdownSalmanoff = false;
std::optional<MrnttNonViralPostingInvoker> initializeCReqInvoker;
std::optional<MrnttNonViralPostingInvoker> finalizeCReqInvoker;
public:
std::exception_ptr initializeLifetimeExceptionPtr;
std::exception_ptr finalizeLifetimeExceptionPtr;
};
extern std::shared_ptr<sscl::PuppeteerThread> thread;
extern MarionetteComponent mrntt;
void marionetteInitializeReqCb(bool success);
void marionetteFinalizeReqCb(bool success);
} // namespace mrntt
} // namespace smo
#endif