|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Base interface for thread pool policies. More...
#include <pool_policy.h>


Public Member Functions | |
| virtual | ~pool_policy ()=default |
| Virtual destructor for proper cleanup. | |
| virtual auto | on_enqueue (job &j) -> common::VoidResult=0 |
| Called before a job is enqueued. | |
| virtual void | on_job_start (job &j)=0 |
| Called when a worker starts executing a job. | |
| virtual void | on_job_complete (job &j, bool success, const std::exception *error=nullptr)=0 |
| Called when a job completes (success or failure). | |
| virtual auto | get_name () const -> std::string=0 |
| Gets the policy name for identification and logging. | |
| virtual auto | is_enabled () const -> bool |
| Checks if the policy is currently enabled. | |
| virtual void | set_enabled (bool enabled) |
| Enables or disables the policy. | |
Base interface for thread pool policies.
Policies provide a way to extend thread pool behavior without modifying the thread_pool class itself. This follows the Strategy pattern and Single Responsibility Principle (SRP).
Policies receive callbacks at key points in the job lifecycle:
on_enqueue(): Called before a job is added to the queueon_job_start(): Called when a worker begins executing a jobon_job_complete(): Called when a job finishes (success or failure)All methods must be thread-safe as they may be called from multiple workers.
Definition at line 80 of file pool_policy.h.
|
virtualdefault |
Virtual destructor for proper cleanup.
|
nodiscardpure virtual |
Gets the policy name for identification and logging.
Implemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
|
inlinenodiscardvirtual |
Checks if the policy is currently enabled.
Reimplemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
Definition at line 146 of file pool_policy.h.
|
pure virtual |
Called before a job is enqueued.
| j | Reference to the job being enqueued. |
Policies can use this to:
Thread Safety:
Implemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
|
pure virtual |
Called when a job completes (success or failure).
| j | Reference to the completed job. |
| success | True if job completed successfully. |
| error | Pointer to exception if job failed, nullptr otherwise. |
Policies can use this to:
Thread Safety:
Implemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
|
pure virtual |
Called when a worker starts executing a job.
| j | Reference to the job being started. |
Policies can use this to:
Thread Safety:
Implemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
|
inlinevirtual |
Enables or disables the policy.
| enabled | Whether to enable the policy. |
Disabled policies have their hooks called but should no-op.
Reimplemented in kcenon::thread::autoscaling_pool_policy, kcenon::thread::circuit_breaker_policy, and kcenon::thread::work_stealing_pool_policy.
Definition at line 154 of file pool_policy.h.