|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Thread-safe crash handler for the entire thread system. More...
#include <crash_handler.h>

Classes | |
| struct | callback_entry |
| struct | cleanup_entry |
| struct | crash_stats |
| Get crash statistics. More... | |
Public Member Functions | |
| void | initialize (crash_safety_level level=crash_safety_level::standard, bool enable_core_dumps=false) |
| Initialize crash handling with specified safety level. | |
| size_t | register_crash_callback (const std::string &name, crash_callback callback, int priority=100) |
| Register a callback to be called during crash handling. | |
| void | unregister_crash_callback (size_t registration_id) |
| Unregister a crash callback. | |
| void | register_cleanup (const std::string &name, std::function< void()> cleanup, uint32_t timeout_ms=1000) |
| Register a resource cleanup function. | |
| void | set_crash_log_directory (const std::string &directory) |
| Set custom crash log directory. | |
| void | set_stack_trace_enabled (bool enable) |
| Enable/disable automatic stack trace generation. | |
| void | trigger_crash_handling (const crash_context &context) |
| Manually trigger crash handling (for testing) | |
| bool | is_handling_crash () const |
| Check if crash handler is currently active. | |
| crash_stats | get_stats () const |
Static Public Member Functions | |
| static crash_handler & | instance () |
| Get the global crash handler instance. | |
Private Member Functions | |
| crash_handler ()=default | |
| ~crash_handler () | |
| crash_handler (const crash_handler &)=delete | |
| crash_handler & | operator= (const crash_handler &)=delete |
| void | handle_crash (int signal) |
| void | execute_callbacks (const crash_context &context) |
| void | execute_cleanups () |
| std::string | generate_stack_trace () |
| void | write_crash_log (const crash_context &context) |
Static Private Member Functions | |
| static void | signal_handler (int signal) |
Private Attributes | |
| crash_safety_level | safety_level_ = crash_safety_level::standard |
| bool | enable_core_dumps_ = false |
| bool | stack_trace_enabled_ = true |
| std::string | crash_log_directory_ = "./crash_logs" |
| std::vector< callback_entry > | callbacks_ |
| std::vector< cleanup_entry > | cleanups_ |
| std::mutex | callbacks_mutex_ |
| std::atomic< size_t > | next_callback_id_ {1} |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< bool > | handling_crash_ {false} |
| std::atomic< size_t > | total_crashes_ {0} |
| std::atomic< size_t > | successful_cleanups_ {0} |
| std::atomic< size_t > | failed_cleanups_ {0} |
| std::chrono::system_clock::time_point | last_crash_time_ |
| struct sigaction | previous_handlers_ [32] |
Thread-safe crash handler for the entire thread system.
Provides comprehensive crash safety mechanisms including:
Definition at line 62 of file crash_handler.h.
|
privatedefault |
|
private |
|
privatedelete |
|
private |
|
private |
|
private |
| crash_stats kcenon::thread::crash_handler::get_stats | ( | ) | const |
Referenced by main().

|
private |
| void kcenon::thread::crash_handler::initialize | ( | crash_safety_level | level = crash_safety_level::standard, |
| bool | enable_core_dumps = false ) |
Initialize crash handling with specified safety level.
| level | Safety level to configure |
| enable_core_dumps | Whether to enable core dump generation |
Referenced by main().

|
static |
Get the global crash handler instance.
Referenced by main(), and kcenon::thread::scoped_crash_callback::~scoped_crash_callback().

| bool kcenon::thread::crash_handler::is_handling_crash | ( | ) | const |
Check if crash handler is currently active.
|
privatedelete |
| void kcenon::thread::crash_handler::register_cleanup | ( | const std::string & | name, |
| std::function< void()> | cleanup, | ||
| uint32_t | timeout_ms = 1000 ) |
Register a resource cleanup function.
| name | Unique name for cleanup |
| cleanup | Function to call for cleanup |
| timeout_ms | Maximum time to wait for cleanup |
Referenced by main().

| size_t kcenon::thread::crash_handler::register_crash_callback | ( | const std::string & | name, |
| crash_callback | callback, | ||
| int | priority = 100 ) |
Register a callback to be called during crash handling.
| name | Unique name for the callback |
| callback | Function to call during crash |
| priority | Priority order (lower numbers called first) |
Referenced by main().

| void kcenon::thread::crash_handler::set_crash_log_directory | ( | const std::string & | directory | ) |
Set custom crash log directory.
| directory | Path to directory for crash logs |
Referenced by main().

| void kcenon::thread::crash_handler::set_stack_trace_enabled | ( | bool | enable | ) |
Enable/disable automatic stack trace generation.
| enable | Whether to generate stack traces |
|
staticprivate |
| void kcenon::thread::crash_handler::trigger_crash_handling | ( | const crash_context & | context | ) |
Manually trigger crash handling (for testing)
| context | Custom crash context |
Referenced by main().

| void kcenon::thread::crash_handler::unregister_crash_callback | ( | size_t | registration_id | ) |
Unregister a crash callback.
| registration_id | ID returned from register_crash_callback |
Referenced by main(), and kcenon::thread::scoped_crash_callback::~scoped_crash_callback().

|
private |
|
private |
Definition at line 176 of file crash_handler.h.
|
mutableprivate |
Definition at line 178 of file crash_handler.h.
|
private |
Definition at line 177 of file crash_handler.h.
|
private |
Definition at line 173 of file crash_handler.h.
|
private |
Definition at line 171 of file crash_handler.h.
|
private |
Definition at line 186 of file crash_handler.h.
|
private |
Definition at line 183 of file crash_handler.h.
|
private |
Definition at line 182 of file crash_handler.h.
|
private |
Definition at line 187 of file crash_handler.h.
|
private |
Definition at line 179 of file crash_handler.h.
|
private |
Definition at line 193 of file crash_handler.h.
|
private |
Definition at line 170 of file crash_handler.h.
|
private |
Definition at line 172 of file crash_handler.h.
|
private |
Definition at line 185 of file crash_handler.h.
|
private |
Definition at line 184 of file crash_handler.h.