|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Crash protection demonstration for thread system. More...
#include <iostream>#include <thread>#include <chrono>#include <random>#include <vector>#include <memory>#include <atomic>#include <kcenon/thread/interfaces/crash_handler.h>#include <kcenon/thread/core/thread_pool.h>#include <kcenon/thread/core/thread_worker.h>#include <kcenon/thread/core/callback_job.h>
Go to the source code of this file.
Classes | |
| class | critical_resource |
Functions | |
| void | simulate_segmentation_fault () |
| void | simulate_division_by_zero () |
| void | simulate_abort () |
| void | normal_task (int task_id) |
| void | potentially_crashing_task (int task_id) |
| void | on_system_crash (const crash_context &context) |
| void | cleanup_global_resources () |
| void | emergency_state_save () |
| int | main () |
Variables | |
| std::atomic< bool > | system_running {true} |
| std::atomic< int > | tasks_completed {0} |
| std::atomic< int > | tasks_failed {0} |
| std::vector< std::shared_ptr< critical_resource > > | global_resources |
Crash protection demonstration for thread system.
Definition in file main.cpp.
| void cleanup_global_resources | ( | ) |
Definition at line 144 of file main.cpp.
References global_resources.
Referenced by main().

| void emergency_state_save | ( | ) |
Definition at line 154 of file main.cpp.
References global_resources, tasks_completed, and tasks_failed.
Referenced by main().

| int main | ( | ) |
Definition at line 161 of file main.cpp.
References cleanup_global_resources(), kcenon::thread::crash_context::crash_time, kcenon::thread::crash_context::crashing_thread, emergency_state_save(), kcenon::thread::thread_pool_crash_safety::enable_for_pool(), kcenon::thread::thread_pool::enqueue(), kcenon::thread::thread_pool::enqueue_batch(), kcenon::thread::crash_context::fault_address, kcenon::thread::crash_handler::get_stats(), global_resources, kcenon::thread::crash_handler::initialize(), kcenon::thread::crash_handler::instance(), normal_task(), on_system_crash(), kcenon::thread::crash_handler::register_cleanup(), kcenon::thread::crash_handler::register_crash_callback(), kcenon::thread::crash_handler::set_crash_log_directory(), kcenon::thread::thread_pool_crash_safety::set_job_crash_handler(), kcenon::thread::crash_context::signal_name, kcenon::thread::crash_context::signal_number, kcenon::thread::crash_context::stack_trace, kcenon::thread::thread_pool::start(), kcenon::thread::thread_pool::stop(), tasks_completed, tasks_failed, kcenon::thread::crash_handler::crash_stats::total_crashes_handled, kcenon::thread::crash_handler::trigger_crash_handling(), and kcenon::thread::crash_handler::unregister_crash_callback().

| void normal_task | ( | int | task_id | ) |
Definition at line 88 of file main.cpp.
References tasks_completed.
Referenced by main().

| void on_system_crash | ( | const crash_context & | context | ) |
Definition at line 129 of file main.cpp.
References kcenon::thread::crash_context::crash_time, kcenon::thread::crash_context::crashing_thread, kcenon::thread::crash_context::signal_name, kcenon::thread::crash_context::signal_number, kcenon::thread::crash_context::stack_trace, and system_running.
Referenced by main().

| void potentially_crashing_task | ( | int | task_id | ) |
Definition at line 98 of file main.cpp.
References simulate_abort(), simulate_division_by_zero(), simulate_segmentation_fault(), tasks_completed, and tasks_failed.

| void simulate_abort | ( | ) |
Definition at line 82 of file main.cpp.
Referenced by potentially_crashing_task().

| void simulate_division_by_zero | ( | ) |
Definition at line 75 of file main.cpp.
Referenced by potentially_crashing_task().

| void simulate_segmentation_fault | ( | ) |
Definition at line 69 of file main.cpp.
Referenced by potentially_crashing_task().

| std::vector<std::shared_ptr<critical_resource> > global_resources |
Definition at line 66 of file main.cpp.
Referenced by cleanup_global_resources(), emergency_state_save(), and main().
| std::atomic<bool> system_running {true} |
Definition at line 35 of file main.cpp.
Referenced by on_system_crash(), and task_scheduling_example().
| std::atomic<int> tasks_completed {0} |
Definition at line 36 of file main.cpp.
Referenced by emergency_state_save(), main(), normal_task(), and potentially_crashing_task().
| std::atomic<int> tasks_failed {0} |
Definition at line 37 of file main.cpp.
Referenced by emergency_state_save(), main(), and potentially_crashing_task().