MOVE_AI/src/component/exiter.cpp
2026-02-28 15:25:24 +08:00

20 lines
381 B
C++

#include "exiter.hpp"
#include <csignal>
#include <stdexcept>
namespace component
{
bool exit_ = false;
bool exiter_inited_ = false;
Exiter::Exiter()
{
if (exiter_inited_) throw std::runtime_error("Multiple Exiter instances!");
std::signal(SIGINT, [](int) { exit_ = true; });
exiter_inited_ = true;
}
bool Exiter::exit() const { return exit_; }
} // namespace component