13 , enabled_(config.enable_work_stealing)
38 return "work_stealing_pool_policy";
43 return enabled_.load(std::memory_order_acquire);
48 enabled_.store(enabled, std::memory_order_release);
Represents an error in the thread system.
Represents a unit of work (task) to be executed, typically by a job queue.
std::atomic< std::uint64_t > failed_steals_
void set_enabled(bool enabled) override
Enables or disables the policy.
void set_steal_backoff(std::chrono::microseconds backoff)
Sets the steal backoff duration.
void set_steal_policy(steal_policy policy)
Sets the steal policy (victim selection strategy).
void set_max_steal_attempts(std::size_t attempts)
Sets the maximum steal attempts per steal cycle.
void set_policy(const worker_policy &config)
Updates the worker policy configuration.
void record_failed_steal()
Records a failed steal attempt.
std::atomic< bool > enabled_
void reset_stats()
Resets the steal statistics.
auto get_steal_backoff() const -> std::chrono::microseconds
Gets the steal backoff duration.
auto get_successful_steals() const -> std::uint64_t
Gets the total number of successful steals.
auto is_enabled() const -> bool override
Checks if the policy is enabled.
auto get_steal_policy() const -> steal_policy
Gets the steal policy (victim selection strategy).
auto get_policy() const -> const worker_policy &
Gets the current worker policy configuration.
void on_job_complete(job &j, bool success, const std::exception *error=nullptr) override
Called when a job completes.
auto on_enqueue(job &j) -> common::VoidResult override
Called before a job is enqueued.
auto get_name() const -> std::string override
Gets the policy name.
work_stealing_pool_policy(const worker_policy &config={})
Constructs a work-stealing policy with the given configuration.
void record_successful_steal()
Records a successful steal operation.
std::atomic< std::uint64_t > successful_steals_
void on_job_start(job &j) override
Called when job starts executing.
auto get_failed_steals() const -> std::uint64_t
Gets the total number of failed steal attempts.
auto get_max_steal_attempts() const -> std::size_t
Gets the maximum steal attempts per steal cycle.
Base job class for schedulable work units in the thread system.
Core threading foundation of the thread system library.
steal_policy
Policy for selecting steal victims.
Worker behavior policy configuration.
std::chrono::microseconds steal_backoff
size_t max_steal_attempts
steal_policy victim_selection
bool enable_work_stealing
Pool policy implementing work-stealing for load balancing.