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.
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
#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 {
|
||||
|
||||
@@ -26,11 +29,17 @@ public:
|
||||
{}
|
||||
~MarionetteComponent() = default;
|
||||
|
||||
public:
|
||||
typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
|
||||
void initializeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
void finalizeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
// Intentionally doesn't take a callback.
|
||||
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;
|
||||
@@ -47,11 +56,14 @@ protected:
|
||||
void handleTryBlock1UnknownException() override;
|
||||
|
||||
private:
|
||||
class MrnttLifetimeMgmtOp;
|
||||
class TerminationEvent;
|
||||
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef SMO_MARIONETTE_THREAD_H
|
||||
#define SMO_MARIONETTE_THREAD_H
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <spinscale/co/invokers.h>
|
||||
#include <spinscale/co/postingPromise.h>
|
||||
|
||||
namespace smo {
|
||||
namespace mrntt {
|
||||
|
||||
struct MrnttThreadTag
|
||||
{
|
||||
static boost::asio::io_service &io_service() noexcept;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using MrnttPostingPromise =
|
||||
sscl::co::TaggedPostingPromise<T, MrnttThreadTag>;
|
||||
|
||||
using MrnttNonViralPostingInvoker =
|
||||
sscl::co::NonViralPostingInvoker<MrnttPostingPromise>;
|
||||
|
||||
template <typename T>
|
||||
using MrnttViralPostingInvoker =
|
||||
sscl::co::ViralPostingInvoker<MrnttPostingPromise, T>;
|
||||
|
||||
using MrnttViralNonPostingInvoker =
|
||||
sscl::co::ViralNonPostingInvoker<void>;
|
||||
|
||||
template <typename T>
|
||||
using MrnttViralNonPostingInvokerT =
|
||||
sscl::co::ViralNonPostingInvoker<T>;
|
||||
|
||||
} // namespace mrntt
|
||||
} // namespace smo
|
||||
|
||||
#endif // SMO_MARIONETTE_THREAD_H
|
||||
Reference in New Issue
Block a user