51 std::unique_lock<std::mutex> lock(
mutex_);
58 bool expected =
false;
60 std::memory_order_release, std::memory_order_relaxed)) {
70 std::lock_guard<std::mutex> lock(
mutex_);
scoped_signal_handler(signal_handler::shutdown_callback callback=nullptr)
Construct and install signal handlers.
auto should_shutdown() const noexcept -> bool
Check if shutdown has been requested.
void wait()
Block until shutdown signal is received.
~scoped_signal_handler()
Destructor - resets signal handler state.
static void wait_for_shutdown()
Block until a shutdown signal is received.
static shutdown_callback callback_
Callback function.
static void install(shutdown_callback callback=nullptr)
Install signal handlers with optional callback.
static auto should_shutdown() noexcept -> bool
Check if shutdown has been requested.
static void handler(int signal)
Signal handler function for C signal API.
static void request_shutdown()
Request shutdown programmatically.
static std::condition_variable cv_
Condition variable for wait_for_shutdown.
static std::atomic< bool > callback_invoked_
Flag to prevent multiple callback invocations.
std::function< void()> shutdown_callback
Callback type for shutdown notification.
static void reset()
Reset the shutdown state.
static std::mutex mutex_
Mutex for condition variable.
static std::atomic< bool > shutdown_requested_
Shutdown flag.
Cross-platform signal handling for graceful shutdown.