72 void stop_by_id(std::uint64_t
id)
noexcept;
81 mutable std::mutex mu_;
82 std::vector<Daemon> daemons_;
83 std::uint64_t next_id_ = 1;
84 bool shutdown_ =
false;
101 : mgr_(other.mgr_), id_(other.id_)
103 other.mgr_ =
nullptr;
114 other.mgr_ =
nullptr;
124 if (mgr_ !=
nullptr && id_ != 0)
126 mgr_->stop_by_id(id_);
132 [[nodiscard]]
bool owns_thread() const noexcept {
return mgr_ !=
nullptr && id_ != 0; }
142 std::uint64_t id_ = 0;
DaemonHandle(const DaemonHandle &)=delete
friend class ThreadManager
DaemonHandle & operator=(const DaemonHandle &)=delete
DaemonHandle & operator=(DaemonHandle &&other) noexcept
bool owns_thread() const noexcept
DaemonHandle() noexcept=default
DaemonHandle(DaemonHandle &&other) noexcept
static ThreadManager & instance()
void add_persistent_daemon(std::string name, DaemonFn fn)
ThreadManager & operator=(const ThreadManager &)=delete
DaemonHandle add_daemon(std::string name, DaemonFn fn)
ThreadManager(const ThreadManager &)=delete
std::size_t daemon_count() const
Number of currently-registered daemons. Test helper.
compat::stop_token stop_token
std::function< void(stop_token)> DaemonFn