23 struct sigaction act {};
24 memset(&act, 0,
sizeof(act));
28 sigaddset(&
set, SIGINT);
29 sigaddset(&
set, SIGTERM);
30 sigaddset(&
set, SIGQUIT);
32 sigaction(SIGINT, &act,
nullptr);
33 sigaction(SIGTERM, &act,
nullptr);
34 sigaction(SIGQUIT, &act,
nullptr);
35 sigprocmask(SIG_UNBLOCK, &act.sa_mask,
nullptr);
39 struct sigaction act {};
40 memset(&act, 0,
sizeof(act));
41 act.sa_handler = SIG_DFL;
44 sigaddset(&
set, SIGINT);
45 sigaddset(&
set, SIGTERM);
46 sigaddset(&
set, SIGQUIT);
48 sigaction(SIGINT, &act,
nullptr);
49 sigaction(SIGTERM, &act,
nullptr);
50 sigaction(SIGQUIT, &act,
nullptr);
54 std::lock_guard lg(
mutex_);
63 std::lock_guard lg(
mutex_);
71 std::lock_guard lg(
mutex_);
79 std::lock_guard lg(
mutex_);
87 std::lock_guard lg(
mutex_);
112 std::lock_guard lg(
mutex_);
137 std::lock_guard lg(
mutex_);
160 throw std::logic_error(
161 "AppStateManager must be instantiated on shared pointer before run");
static std::weak_ptr< AppStateManager > wp_to_myself
std::queue< OnLaunch > launch_
~AppStateManagerImpl() override
void run() override
Start application life cycle.
std::function< bool()> OnLaunch
static void shuttingDownSignalsHandler(int)
std::condition_variable cv_
void atShutdown(OnShutdown &&cb) override
Execute.
void atPrepare(OnPrepare &&cb) override
Execute.
std::queue< OnPrepare > prepare_
std::atomic_bool shutdown_requested_
void atLaunch(OnLaunch &&cb) override
Execute.
void shutdown() override
Initiate shutting down (at any time)
std::atomic< State > state_
std::function< bool()> OnPrepare
void doPrepare() override
void doShutdown() override
std::queue< OnShutdown > shutdown_
std::recursive_mutex mutex_
Logger createLogger(const std::string &tag)
std::function< void()> OnShutdown