76 bool enable_core_dumps =
false);
102 std::function<
void()> cleanup,
103 uint32_t timeout_ms = 1000);
191 void* previous_handler_ =
nullptr;
Thread-safe crash handler for the entire thread system.
std::atomic< bool > initialized_
std::vector< cleanup_entry > cleanups_
void unregister_crash_callback(size_t registration_id)
Unregister a crash callback.
struct sigaction previous_handlers_[32]
void write_crash_log(const crash_context &context)
crash_safety_level safety_level_
std::string generate_stack_trace()
std::atomic< size_t > next_callback_id_
std::atomic< size_t > failed_cleanups_
void initialize(crash_safety_level level=crash_safety_level::standard, bool enable_core_dumps=false)
Initialize crash handling with specified safety level.
void handle_crash(int signal)
void register_cleanup(const std::string &name, std::function< void()> cleanup, uint32_t timeout_ms=1000)
Register a resource cleanup function.
bool is_handling_crash() const
Check if crash handler is currently active.
std::mutex callbacks_mutex_
std::chrono::system_clock::time_point last_crash_time_
void execute_callbacks(const crash_context &context)
static crash_handler & instance()
Get the global crash handler instance.
static void signal_handler(int signal)
crash_stats get_stats() const
std::atomic< size_t > total_crashes_
void set_stack_trace_enabled(bool enable)
Enable/disable automatic stack trace generation.
std::atomic< bool > handling_crash_
crash_handler(const crash_handler &)=delete
bool stack_trace_enabled_
size_t register_crash_callback(const std::string &name, crash_callback callback, int priority=100)
Register a callback to be called during crash handling.
std::string crash_log_directory_
void set_crash_log_directory(const std::string &directory)
Set custom crash log directory.
std::vector< callback_entry > callbacks_
void trigger_crash_handling(const crash_context &context)
Manually trigger crash handling (for testing)
std::atomic< size_t > successful_cleanups_
crash_handler & operator=(const crash_handler &)=delete
RAII helper for automatic crash callback registration.
scoped_crash_callback & operator=(scoped_crash_callback &&)=default
scoped_crash_callback(scoped_crash_callback &&)=default
scoped_crash_callback(const scoped_crash_callback &)=delete
scoped_crash_callback & operator=(const scoped_crash_callback &)=delete
scoped_crash_callback(const std::string &name, crash_callback callback, int priority=100)
Thread pool crash safety extensions.
static void set_job_crash_handler(std::function< void(const std::string &pool_name, const crash_context &)> handler)
Register job crash handler.
static void handle_job_crash(const std::string &pool_name, const crash_context &context)
static void enable_for_pool(const std::string &pool_name, class thread_pool &pool)
Enable crash safety for a thread pool.
A thread pool for concurrent execution of jobs using multiple worker threads.
@ callback
Call user callback for custom decision.
Core threading foundation of the thread system library.
crash_safety_level
Crash safety levels for different scenarios.
std::function< void(const crash_context &)> crash_callback
Callback function type for crash handling.
@ priority
Priority-based scheduling.
Crash context information.
std::chrono::system_clock::time_point crash_time
std::thread::id crashing_thread
std::function< void()> cleanup
size_t successful_cleanups
std::chrono::system_clock::time_point last_crash_time
size_t total_crashes_handled