|
PACS System 0.1.0
PACS DICOM system library
|
#include <signal_handler.h>

Public Types | |
| using | shutdown_callback = std::function<void()> |
| Callback type for shutdown notification. | |
Static Public Member Functions | |
| 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 | wait_for_shutdown () |
| Block until a shutdown signal is received. | |
| static void | request_shutdown () |
| Request shutdown programmatically. | |
| static void | reset () |
| Reset the shutdown state. | |
Static Private Member Functions | |
| static void | handler (int signal) |
| Signal handler function for C signal API. | |
Static Private Attributes | |
| static std::atomic< bool > | shutdown_requested_ {false} |
| Shutdown flag. | |
| static shutdown_callback | callback_ |
| Callback function. | |
| static std::mutex | mutex_ |
| Mutex for condition variable. | |
| static std::condition_variable | cv_ |
| Condition variable for wait_for_shutdown. | |
| static std::atomic< bool > | callback_invoked_ {false} |
| Flag to prevent multiple callback invocations. | |
Definition at line 42 of file signal_handler.h.
| using kcenon::pacs::samples::signal_handler::shutdown_callback = std::function<void()> |
Callback type for shutdown notification.
Definition at line 45 of file signal_handler.h.
|
staticprivate |
Signal handler function for C signal API.
Definition at line 76 of file signal_handler.cpp.
References request_shutdown().
Referenced by install().


|
static |
Install signal handlers with optional callback.
| callback | Function to call when shutdown signal is received |
Installs handlers for SIGINT and SIGTERM (POSIX) or SIGINT and SIGBREAK (Windows). The callback is invoked once when the first signal is received.
Definition at line 32 of file signal_handler.cpp.
References callback_, callback_invoked_, handler(), and shutdown_requested_.
Referenced by kcenon::pacs::samples::scoped_signal_handler::scoped_signal_handler().


|
static |
Request shutdown programmatically.
Sets the shutdown flag and notifies waiting threads. Useful for triggering shutdown from application code.
Definition at line 57 of file signal_handler.cpp.
References callback_, callback_invoked_, cv_, and shutdown_requested_.
Referenced by handler().

|
static |
Reset the shutdown state.
Clears the shutdown flag. Useful for tests or when restarting a service within the same process.
Definition at line 69 of file signal_handler.cpp.
References callback_, callback_invoked_, mutex_, and shutdown_requested_.
Referenced by kcenon::pacs::samples::scoped_signal_handler::~scoped_signal_handler().

|
staticnodiscardnoexcept |
Check if shutdown has been requested.
Definition at line 46 of file signal_handler.cpp.
References shutdown_requested_.
Referenced by kcenon::pacs::samples::scoped_signal_handler::should_shutdown().

|
static |
Block until a shutdown signal is received.
This method blocks the calling thread until SIGINT/SIGTERM is received. Useful for main threads that need to wait for graceful shutdown.
Definition at line 50 of file signal_handler.cpp.
References cv_, mutex_, and shutdown_requested_.
Referenced by kcenon::pacs::samples::scoped_signal_handler::wait().

|
staticprivate |
Callback function.
Definition at line 100 of file signal_handler.h.
Referenced by install(), request_shutdown(), and reset().
|
staticprivate |
Flag to prevent multiple callback invocations.
Definition at line 109 of file signal_handler.h.
Referenced by install(), request_shutdown(), and reset().
|
staticprivate |
Condition variable for wait_for_shutdown.
Definition at line 106 of file signal_handler.h.
Referenced by request_shutdown(), and wait_for_shutdown().
|
staticprivate |
Mutex for condition variable.
Definition at line 103 of file signal_handler.h.
Referenced by reset(), and wait_for_shutdown().
|
staticprivate |
Shutdown flag.
Definition at line 97 of file signal_handler.h.
Referenced by install(), request_shutdown(), reset(), should_shutdown(), and wait_for_shutdown().