|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Cooperative job cancellation and graceful shutdown patterns. More...
#include <kcenon/thread/core/thread_pool.h>#include <kcenon/thread/core/job.h>#include <kcenon/thread/core/thread_worker.h>#include <kcenon/thread/utils/formatter.h>#include <iostream>#include <chrono>#include <thread>#include <atomic>
Go to the source code of this file.
Classes | |
| class | cancellable_long_job |
| A job that performs a long-running task with periodic cancellation checks. More... | |
| class | non_cancellable_job |
| A job that DOES NOT check for cancellation (anti-pattern). More... | |
Functions | |
| void | demo_basic_cancellation () |
| Demonstrates basic job cancellation via worker stop. | |
| void | demo_non_cooperative_job () |
| Demonstrates what happens with non-cooperating jobs. | |
| void | demo_pool_level_cancellation () |
| Demonstrates pool-level cancellation with multiple workers. | |
| void | demo_immediate_vs_graceful () |
| Demonstrates immediate vs. graceful shutdown. | |
| int | main () |
Cooperative job cancellation and graceful shutdown patterns.
Definition in file job_cancellation_example.cpp.
| void demo_basic_cancellation | ( | ) |
Demonstrates basic job cancellation via worker stop.
Shows how stopping a worker cancels the currently running job.
Definition at line 137 of file job_cancellation_example.cpp.
References kcenon::thread::utils::formatter::format().
Referenced by main().


| void demo_immediate_vs_graceful | ( | ) |
Demonstrates immediate vs. graceful shutdown.
Definition at line 256 of file job_cancellation_example.cpp.
References kcenon::thread::utils::formatter::format().
Referenced by main().


| void demo_non_cooperative_job | ( | ) |
Demonstrates what happens with non-cooperating jobs.
Shows the limitation of cooperative cancellation - jobs must check the token.
Definition at line 174 of file job_cancellation_example.cpp.
References kcenon::thread::utils::formatter::format().
Referenced by main().


| void demo_pool_level_cancellation | ( | ) |
Demonstrates pool-level cancellation with multiple workers.
Shows hierarchical cancellation propagating to all workers.
Definition at line 214 of file job_cancellation_example.cpp.
References kcenon::thread::utils::formatter::format().
Referenced by main().


| int main | ( | ) |
Definition at line 309 of file job_cancellation_example.cpp.
References demo_basic_cancellation(), demo_immediate_vs_graceful(), demo_non_cooperative_job(), and demo_pool_level_cancellation().
