2025-09-28 23:07:39 -04:00
|
|
|
#ifndef DEVICEREATTACHER_H
|
|
|
|
|
#define DEVICEREATTACHER_H
|
|
|
|
|
|
2026-05-24 16:12:29 -04:00
|
|
|
#include <functional>
|
2025-09-28 23:07:39 -04:00
|
|
|
#include <memory>
|
2025-10-16 01:00:48 -04:00
|
|
|
#include <boost/asio/deadline_timer.hpp>
|
2026-06-09 11:19:42 -04:00
|
|
|
#include <spinscale/co/dynamicPostingInvoker.h>
|
|
|
|
|
#include <spinscale/co/nonViralTaskNursery.h>
|
|
|
|
|
#include <spinscale/co/postTarget.h>
|
2026-05-30 10:52:15 -04:00
|
|
|
#include <spinscale/syncCancelerForAsyncWork.h>
|
2025-09-28 23:07:39 -04:00
|
|
|
|
|
|
|
|
namespace smo {
|
|
|
|
|
|
|
|
|
|
namespace device {
|
|
|
|
|
|
|
|
|
|
class DeviceManager;
|
|
|
|
|
|
|
|
|
|
class DeviceReattacher
|
|
|
|
|
{
|
|
|
|
|
public:
|
2026-05-24 16:12:29 -04:00
|
|
|
DeviceReattacher(
|
2025-12-27 16:21:22 -04:00
|
|
|
DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread);
|
2026-05-24 16:12:29 -04:00
|
|
|
~DeviceReattacher() = default;
|
2025-09-28 23:07:39 -04:00
|
|
|
|
2026-05-24 16:12:29 -04:00
|
|
|
DeviceReattacher(const DeviceReattacher&) = delete;
|
|
|
|
|
DeviceReattacher& operator=(const DeviceReattacher&) = delete;
|
2025-09-28 23:07:39 -04:00
|
|
|
|
2026-05-24 16:12:29 -04:00
|
|
|
// Control methods
|
|
|
|
|
void start();
|
|
|
|
|
void stop();
|
2025-09-28 23:07:39 -04:00
|
|
|
|
|
|
|
|
private:
|
2026-06-09 11:19:42 -04:00
|
|
|
sscl::co::DynamicNonViralPostingInvoker deviceReattacherCDaemon(
|
|
|
|
|
sscl::co::ExplicitPostTarget postTarget,
|
2026-05-24 16:12:29 -04:00
|
|
|
std::exception_ptr &exceptionPtr,
|
2026-06-09 11:19:42 -04:00
|
|
|
std::function<void()> callback,
|
|
|
|
|
sscl::SyncCancelerForAsyncWork &canceler);
|
2026-05-24 16:12:29 -04:00
|
|
|
|
|
|
|
|
DeviceManager &parent;
|
2026-06-09 11:19:42 -04:00
|
|
|
// io_context thread for timer (see ctor).
|
2026-05-24 16:12:29 -04:00
|
|
|
std::shared_ptr<sscl::ComponentThread> ioThread;
|
2026-06-09 11:19:42 -04:00
|
|
|
sscl::co::NonViralTaskNursery taskNursery;
|
|
|
|
|
boost::asio::deadline_timer daemonTimer;
|
2025-09-28 23:07:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace device
|
|
|
|
|
} // namespace smo
|
|
|
|
|
|
|
|
|
|
#endif // DEVICEREATTACHER_H
|