Exceptions: Straight line convention refactor
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <marionette/marionette.h>
|
||||
#include <marionette/marionetteThread.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <spinscale/co/nonViralCompletion.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
|
||||
namespace smo {
|
||||
@@ -31,17 +32,31 @@ void assertMarionetteThread()
|
||||
void MarionetteComponent::holdInitializeCReq(
|
||||
std::function<void()> completion)
|
||||
{
|
||||
initializeLifetimeSucceeded = false;
|
||||
initializeLifetimeExceptionPtr = nullptr;
|
||||
initializeCReqInvoker.emplace(initializeCReq(
|
||||
initializeLifetimeExceptionPtr, std::move(completion)));
|
||||
initializeLifetimeExceptionPtr,
|
||||
[completion = std::move(completion)]()
|
||||
{
|
||||
sscl::co::NonViralCompletion nvc(
|
||||
mrntt.initializeLifetimeExceptionPtr);
|
||||
nvc.checkAndRethrowException();
|
||||
completion();
|
||||
}));
|
||||
}
|
||||
|
||||
void MarionetteComponent::holdFinalizeCReq(
|
||||
std::function<void()> completion)
|
||||
{
|
||||
finalizeLifetimeExceptionPtr = nullptr;
|
||||
finalizeCReqInvoker.emplace(finalizeCReq(
|
||||
finalizeLifetimeExceptionPtr, std::move(completion)));
|
||||
finalizeLifetimeExceptionPtr,
|
||||
[completion = std::move(completion)]()
|
||||
{
|
||||
sscl::co::NonViralCompletion nvc(
|
||||
mrntt.finalizeLifetimeExceptionPtr);
|
||||
nvc.checkAndRethrowException();
|
||||
completion();
|
||||
}));
|
||||
}
|
||||
|
||||
MrnttNonViralPostingInvoker MarionetteComponent::initializeCReq(
|
||||
@@ -52,15 +67,8 @@ MrnttNonViralPostingInvoker MarionetteComponent::initializeCReq(
|
||||
|
||||
smo::mind::globalMind = std::make_shared<smo::Mind>();
|
||||
|
||||
bool mindInitialized = co_await smo::mind::globalMind->initializeCReq();
|
||||
if (!mindInitialized)
|
||||
{
|
||||
std::cerr << __func__ << ": Failed to initialize globalMind"
|
||||
<< std::endl;
|
||||
co_return;
|
||||
}
|
||||
co_await smo::mind::globalMind->initializeCReq();
|
||||
|
||||
initializeLifetimeSucceeded = true;
|
||||
smo::device::DeviceManager::getInstance().initializeDeviceReattacher();
|
||||
|
||||
// Call negtrinEventInd on the Director in the final callback
|
||||
@@ -77,17 +85,9 @@ MrnttNonViralPostingInvoker MarionetteComponent::finalizeCReq(
|
||||
|
||||
smo::device::DeviceManager::getInstance().finalizeDeviceReattacher();
|
||||
|
||||
if (!smo::mind::globalMind)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
if (!smo::mind::globalMind) { co_return; }
|
||||
|
||||
bool mindFinalized = co_await smo::mind::globalMind->finalizeCReq();
|
||||
if (!mindFinalized)
|
||||
{
|
||||
std::cerr << __func__ << ": globalMind finalization failed"
|
||||
<< std::endl;
|
||||
}
|
||||
co_await smo::mind::globalMind->finalizeCReq();
|
||||
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -129,12 +129,7 @@ void MarionetteComponent::preLoopHook()
|
||||
callShutdownSalmanoff = true;
|
||||
|
||||
holdInitializeCReq(
|
||||
[]
|
||||
{
|
||||
marionetteInitializeReqCb(
|
||||
mrntt.initializeLifetimeSucceeded
|
||||
&& !mrntt.initializeLifetimeExceptionPtr);
|
||||
});
|
||||
[] { marionetteInitializeReqCb(true); });
|
||||
|
||||
std::cout << "PuppeteerThread::main: Entering event loop" << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user