/* * @Author: DI JUNKUN * @Date: 2025-11-19 * Copyright (c) 2025 by DI JUNKUN, All Rights Reserved. */ #ifndef _DAEMON_H_ #define _DAEMON_H_ #include #include #include #include class Daemon { public: using MainLoopFunc = std::function; Daemon(const std::string& name); bool start(MainLoopFunc loop); void stop(); bool isRunning() const; private: std::string name_; bool runWithRestart(MainLoopFunc loop); #ifndef _WIN32 static volatile std::sig_atomic_t stop_requested_; #endif std::atomic running_; }; #endif