Files
salmanoff/smocore/include/deviceManager/deviceReattacher.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

60 lines
1.4 KiB
C++

#ifndef DEVICEREATTACHER_H
#define DEVICEREATTACHER_H
#include <boostAsioLinkageFix.h>
#include <atomic>
#include <chrono>
#include <exception>
#include <functional>
#include <memory>
#include <optional>
#include <boost/asio/deadline_timer.hpp>
#include <marionette/marionetteThread.h>
#include <spinscale/multiOperationResultSet.h>
#include <spinscale/spinLock.h>
namespace smo {
namespace device {
class DeviceManager;
class DeviceReattacher
{
public:
DeviceReattacher(
DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread);
~DeviceReattacher() = default;
DeviceReattacher(const DeviceReattacher&) = delete;
DeviceReattacher& operator=(const DeviceReattacher&) = delete;
// Control methods
void start();
void stop();
private:
void scheduleNextTimeout();
void onTimeout(const boost::system::error_code& error);
void holdReattachCReq();
mrntt::MrnttNonViralPostingInvoker reattachKnownListCReq(
std::exception_ptr &exceptionPtr,
std::function<void()> callback);
DeviceManager &parent;
std::shared_ptr<sscl::ComponentThread> ioThread;
sscl::SpinLock shouldContinueLock;
bool shouldContinue;
boost::asio::deadline_timer timer;
std::exception_ptr reattachLifetimeExceptionPtr;
std::optional<mrntt::MrnttNonViralPostingInvoker> reattachCReqInvoker;
bool reattachOpInFlight = false;
std::chrono::steady_clock::time_point lastReattachReqTimestamp{};
};
} // namespace device
} // namespace smo
#endif // DEVICEREATTACHER_H