Async: Drop-in SyncCancelerForAsyncWork without execUncancelableSegment*
We're doing this to prep for the coro port
This commit is contained in:
@@ -18,8 +18,7 @@ constexpr unsigned int reattachInFlightStaleThresholdMultiplier = 4;
|
||||
|
||||
DeviceReattacher::DeviceReattacher(
|
||||
DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread)
|
||||
: parent(parent), ioThread(ioThread), shouldContinue(false),
|
||||
timer(ioThread->getIoService())
|
||||
: parent(parent), ioThread(ioThread), timer(ioThread->getIoService())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,16 +40,16 @@ mrntt::MrnttNonViralPostingInvoker DeviceReattacher::reattachKnownListCReq(
|
||||
|
||||
void DeviceReattacher::start()
|
||||
{
|
||||
shouldContinue = true;
|
||||
deviceReattacherCanceler.startAcceptingWork();
|
||||
scheduleNextTimeout();
|
||||
}
|
||||
|
||||
void DeviceReattacher::stop()
|
||||
{
|
||||
{
|
||||
sscl::SpinLock::Guard lock(shouldContinueLock);
|
||||
shouldContinue = false;
|
||||
sscl::SpinLock::Guard guard(deviceReattacherCanceler.s.lock);
|
||||
reattachOpInFlight = false;
|
||||
deviceReattacherCanceler.s.rsrc.shouldContinue = false;
|
||||
/** EXPLANATION:
|
||||
* Do not call reattachCReqInvoker.reset() here. Forcibly destroying
|
||||
* the invoker would tear down an in-flight reattach coroutine frame
|
||||
@@ -65,7 +64,7 @@ void DeviceReattacher::stop()
|
||||
|
||||
void DeviceReattacher::scheduleNextTimeout()
|
||||
{
|
||||
if (!shouldContinue) {
|
||||
if (deviceReattacherCanceler.isCancellationRequestedUnlocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ void DeviceReattacher::holdReattachCReq()
|
||||
reattachLifetimeExceptionPtr,
|
||||
[this]()
|
||||
{
|
||||
sscl::SpinLock::Guard lock(shouldContinueLock);
|
||||
sscl::SpinLock::Guard guard(deviceReattacherCanceler.s.lock);
|
||||
reattachOpInFlight = false;
|
||||
}));
|
||||
}
|
||||
@@ -107,8 +106,8 @@ void DeviceReattacher::onTimeout(const boost::system::error_code& error)
|
||||
return;
|
||||
}
|
||||
|
||||
sscl::SpinLock::Guard lock(shouldContinueLock);
|
||||
if (!shouldContinue) {
|
||||
sscl::SpinLock::Guard guard(deviceReattacherCanceler.s.lock);
|
||||
if (deviceReattacherCanceler.isCancellationRequestedUnlocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <marionette/marionetteThread.h>
|
||||
#include <spinscale/multiOperationResultSet.h>
|
||||
#include <spinscale/spinLock.h>
|
||||
#include <spinscale/syncCancelerForAsyncWork.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
@@ -44,8 +44,7 @@ private:
|
||||
|
||||
DeviceManager &parent;
|
||||
std::shared_ptr<sscl::ComponentThread> ioThread;
|
||||
sscl::SpinLock shouldContinueLock;
|
||||
bool shouldContinue;
|
||||
sscl::SyncCancelerForAsyncWork deviceReattacherCanceler;
|
||||
boost::asio::deadline_timer timer;
|
||||
std::exception_ptr reattachLifetimeExceptionPtr;
|
||||
std::optional<mrntt::MrnttNonViralPostingInvoker> reattachCReqInvoker;
|
||||
|
||||
Reference in New Issue
Block a user