|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Core threading foundation of the thread system library. More...
Namespaces | |
| namespace | adapters |
| namespace | concepts |
| namespace | config |
| namespace | core |
| namespace | detail |
| namespace | diagnostics |
| namespace | impl |
| namespace | interfaces |
| namespace | job_detail |
| namespace | jobs |
| namespace | lockfree |
| namespace | metrics |
| namespace | platform |
| namespace | policies |
| namespace | sync |
| namespace | utility_module |
| namespace | utils |
Classes | |
| class | adaptive_job_queue |
| Adaptive queue that switches between mutex and lock-free modes. More... | |
| struct | aged_priority |
| Priority with aging support. More... | |
| struct | aging_stats |
| Statistics about priority aging behavior. More... | |
| class | aging_typed_job_queue_t |
| A typed job queue with priority aging support, based on policy_queue. More... | |
| class | aging_typed_job_t |
| A typed job with priority aging support. More... | |
| class | atomic_shared_ptr |
| class | atomic_wait_helper |
| Helper class to add wait/notify functionality to std::atomic. More... | |
| class | atomic_with_wait |
| RAII wrapper to add wait/notify to atomic variables. More... | |
| class | autoscaler |
| Manages automatic scaling of thread pool workers based on load metrics. More... | |
| struct | autoscaling_policy |
| Configuration for autoscaling behavior. More... | |
| class | autoscaling_pool_policy |
| Pool policy that implements automatic scaling for dynamic worker management. More... | |
| struct | autoscaling_stats |
| Statistics for autoscaling operations. More... | |
| class | backoff_calculator |
| Calculates backoff delays for work-stealing operations. More... | |
| struct | backpressure_config |
| Configuration for backpressure mechanisms. More... | |
| class | backpressure_job_queue |
| A job queue with comprehensive backpressure mechanisms. More... | |
| struct | backpressure_stats |
| Thread-safe statistics for backpressure operations. More... | |
| struct | backpressure_stats_snapshot |
| Snapshot of backpressure statistics (copyable). More... | |
| class | barrier |
| C++17-compatible barrier implementation. More... | |
| class | callback_job |
| A specialized job class that encapsulates user-defined callbacks. More... | |
| class | callback_typed_job_t |
| Callback-based typed job template. More... | |
| class | cancellable_future |
| A future wrapper that supports cancellation. More... | |
| class | cancellable_future< void > |
| Specialization for void return type. More... | |
| class | cancellation_callback_guard |
| RAII guard for automatic callback unregistration. More... | |
| class | cancellation_context |
| Thread-local cancellation context for implicit token propagation. More... | |
| struct | cancellation_reason |
| Holds information about why a cancellation occurred. More... | |
| class | cancellation_scope |
| Structured cancellation scope with check points. More... | |
| class | cancellation_token |
| Provides a mechanism for cooperative cancellation of operations. More... | |
| class | circuit_breaker_policy |
| Pool policy that implements circuit breaker pattern for failure protection. More... | |
| class | config_builder |
| Builder for thread_system_config. More... | |
| struct | config_changed_event |
| Configuration changed event. More... | |
| class | configuration_manager |
| Configuration manager for unified system configuration. More... | |
| struct | crash_context |
| Crash context information. More... | |
| class | crash_handler |
| Thread-safe crash handler for the entire thread system. More... | |
| struct | dag_config |
| Configuration options for the DAG scheduler. More... | |
| class | dag_job |
| A job with dependency support for DAG-based scheduling. More... | |
| class | dag_job_builder |
| Fluent builder for creating dag_job instances. More... | |
| struct | dag_job_info |
| Information about a job in the DAG. More... | |
| class | dag_scheduler |
| DAG-based job scheduler with dependency management. More... | |
| struct | dag_stats |
| Statistics about DAG execution. More... | |
| class | default_error_handler |
| Default error handler implementation. More... | |
| class | enhanced_cancellation_token |
| Advanced cancellation token with timeout, deadline, and reason support. More... | |
| struct | enhanced_work_stealing_config |
| Configuration for enhanced work-stealing with NUMA awareness. More... | |
| class | error |
| Represents an error in the thread system. More... | |
| class | error_handler |
| Error handler interface. More... | |
| class | event_base |
| Event base class for type safety. More... | |
| class | event_bus |
| Event Bus for publish-subscribe pattern. More... | |
| class | future_job |
| A job that wraps a callable and provides a future for its result. More... | |
| struct | has_blocking_overflow |
| Compile-time detection of blocking overflow policy. More... | |
| struct | has_blocking_overflow< T, std::enable_if_t< policy_queue_traits< T >::is_policy_queue > > |
| class | hazard_pointer |
| Single hazard pointer that protects one object from reclamation Uses RAII pattern - automatically releases protection on destruction. More... | |
| class | hazard_pointer_domain |
| Domain managing hazard pointers and retirement for a specific type. More... | |
| struct | is_bounded_queue |
| Compile-time detection of bounded queue. More... | |
| struct | is_bounded_queue< T, std::enable_if_t< policy_queue_traits< T >::is_policy_queue > > |
| struct | is_lockfree_queue |
| Compile-time detection of lock-free capability. More... | |
| struct | is_lockfree_queue< T, std::enable_if_t< policy_queue_traits< T >::is_policy_queue > > |
| class | job |
| Represents a unit of work (task) to be executed, typically by a job queue. More... | |
| class | job_builder |
| Fluent builder for creating and configuring jobs with composition. More... | |
| struct | job_components |
| Internal structure holding composed behaviors for a job. More... | |
| struct | job_info |
| Information about a job for starvation callback. More... | |
| class | job_queue |
| A thread-safe job queue for managing and dispatching work items. More... | |
| class | job_queue_adapter |
| Adapter for job_queue to pool_queue_adapter_interface. More... | |
| class | latch |
| C++17-compatible latch implementation. More... | |
| class | lifecycle_controller |
| Centralized thread lifecycle state and synchronization management. More... | |
| struct | module_version |
| Version information for thread_system module. More... | |
| struct | numa_node |
| Information about a single NUMA node. More... | |
| class | numa_thread_pool |
| A NUMA-aware thread pool optimized for Non-Uniform Memory Access architectures. More... | |
| class | numa_topology |
| NUMA (Non-Uniform Memory Access) topology information. More... | |
| class | numa_work_stealer |
| NUMA-aware work stealer with enhanced victim selection policies. More... | |
| class | operation_cancelled_exception |
| Exception thrown when an operation is cancelled. More... | |
| struct | performance_alert_event |
| Performance alert event. More... | |
| class | policy_queue |
| Policy-based queue template. More... | |
| class | policy_queue_adapter |
| Adapter for policy_queue to pool_queue_adapter_interface. More... | |
| struct | policy_queue_traits |
| Extract policy types from a policy_queue. More... | |
| struct | policy_queue_traits< T, std::enable_if_t< detail::has_sync_policy_type< T >::value &&detail::has_bound_policy_type< T >::value &&detail::has_overflow_policy_type< T >::value > > |
| class | pool_future |
| A future that can be scheduled on a thread pool. More... | |
| class | pool_policy |
| Base interface for thread pool policies. More... | |
| class | pool_promise |
| A promise that can schedule work on a thread pool. More... | |
| class | pool_promise< void > |
| Specialization for void type. More... | |
| class | pool_queue_adapter_interface |
| Abstract interface for queue adapters used by thread_pool. More... | |
| struct | priority_aging_config |
| Configuration for priority aging behavior. More... | |
| class | protected_job |
| A job wrapper that integrates circuit breaker protection. More... | |
| struct | queue_capabilities |
| Runtime-queryable queue capabilities descriptor. More... | |
| class | queue_capabilities_interface |
| Mixin interface for queue capability introspection. More... | |
| class | queue_factory |
| Factory for creating queue instances. More... | |
| struct | queue_type_selector |
| Compile-time queue type selector. More... | |
| class | result |
| A template class representing either a value or an error. More... | |
| class | result< void > |
| Specialization of result for void. More... | |
| class | result_void |
| Wrapper for void result. More... | |
| class | retry_policy |
| Encapsulates retry behavior configuration for jobs. More... | |
| class | safe_hazard_guard |
| class | safe_hazard_pointer_domain |
| Global Hazard Pointer Domain Manager. More... | |
| class | safe_hazard_pointer_record |
| Thread-local hazard pointer record with explicit memory ordering. More... | |
| struct | scaling_decision |
| Scaling decision result. More... | |
| struct | scaling_metrics_sample |
| Metrics sample for autoscaling decisions. More... | |
| class | scheduler_interface |
| Scheduler interface for queuing and retrieving jobs. More... | |
| class | scoped_crash_callback |
| RAII helper for automatic crash callback registration. More... | |
| class | scoped_service |
| RAII helper for scoped service registration. More... | |
| class | service_container |
| Modern service container for dependency injection. More... | |
| class | service_registry |
| Lightweight service registry for dependency lookup. More... | |
| struct | steal_backoff_config |
| Configuration for backoff behavior. More... | |
| struct | submit_options |
| Options for submitting jobs to the thread pool. More... | |
| struct | system_shutdown_event |
| System shutdown event. More... | |
| struct | system_startup_event |
| System startup event. More... | |
| class | thread_base |
| A foundational class for implementing custom worker threads. More... | |
| class | thread_context |
| Context object that provides access to optional services. More... | |
| class | thread_context_builder |
| Builder for thread_context with fluent interface. More... | |
| class | thread_error_category |
| std::error_category implementation for thread_system errors More... | |
| class | thread_logger |
| Structured logger for thread system. More... | |
| class | thread_pool |
| A thread pool for concurrent execution of jobs using multiple worker threads. More... | |
| class | thread_pool_builder |
| Fluent builder for creating and configuring thread pools. More... | |
| class | thread_pool_crash_safety |
| Thread pool crash safety extensions. More... | |
| struct | thread_system_config |
| Unified configuration for thread_system. More... | |
| class | thread_worker |
A specialized worker thread that processes jobs from a job_queue. More... | |
| class | token_bucket |
| Lock-free token bucket rate limiter for controlling throughput. More... | |
| class | typed_job_factory_interface |
| Factory interface for creating typed jobs. More... | |
| class | typed_job_interface |
| Typed job interface template. More... | |
| class | typed_job_t |
| Typed job template. More... | |
| class | typed_safe_hazard_domain |
| Typed hazard pointer domain. More... | |
| class | typed_thread_pool_builder |
| Typed thread pool builder template. More... | |
| class | typed_thread_pool_t |
| Typed thread pool template. More... | |
| class | typed_thread_worker_t |
| Typed thread worker template. More... | |
| struct | validation_result |
| Configuration validation result. More... | |
| class | work_affinity_tracker |
| Tracks cooperation patterns between workers for locality-aware stealing. More... | |
| class | work_stealing_pool_policy |
| Pool policy that implements work-stealing behavior for load balancing. More... | |
| struct | work_stealing_stats |
| Statistics for work-stealing operations. More... | |
| struct | work_stealing_stats_snapshot |
| Non-atomic snapshot of work-stealing statistics. More... | |
| struct | worker_policy |
| Worker behavior policy configuration. More... | |
Typedefs | |
| template<typename T > | |
| using | result_t = result<T> |
| using | standard_queue_adapter |
| Adapter for standard_queue (mutex-based, unbounded) | |
| using | lockfree_queue_adapter |
| Adapter for lock-free queue. | |
| using | config_value |
| Configuration value type. | |
| using | standard_queue |
| Standard mutex-based unbounded queue. | |
| using | policy_lockfree_queue |
| Lock-free unbounded queue. | |
| using | job_id = std::uint64_t |
| Unique job identifier for DAG scheduler. | |
| using | aging_typed_job = aging_typed_job_t<job_types> |
| A convenient alias for aging_typed_job_t using the job_types type. | |
| using | aging_typed_job_queue = aging_typed_job_queue_t<job_types> |
| A convenient alias for aging_typed_job_queue_t using the job_types type. | |
| using | callback_typed_job = callback_typed_job_t<job_types> |
Type alias for a callback_typed_job_t that uses job_types as its priority type. | |
| using | typed_job = typed_job_t<job_types> |
A convenient alias for typed_job_t using the job_types type. | |
| template<detail::JobType job_type> | |
| using | typed_job_ptr = std::shared_ptr<typed_job_interface<job_type>> |
| Shared pointer type for typed job interfaces. | |
| template<detail::JobType job_type> | |
| using | typed_job_weak_ptr = std::weak_ptr<typed_job_interface<job_type>> |
| Weak pointer type for typed job interfaces. | |
| using | typed_thread_pool = typed_thread_pool_t<job_types> |
| Alias for a typed_thread_pool with the default job_types type. | |
| using | typed_thread_worker = typed_thread_worker_t<job_types> |
| Convenience typedef for a worker configured with default job_types. | |
| using | crash_callback = std::function<void(const crash_context&)> |
| Callback function type for crash handling. | |
| using | ILogger = common::interfaces::ILogger |
| using | IMonitor = common::interfaces::IMonitor |
| template<std::size_t MaxSize> | |
| using | bounded_blocking_queue |
| Bounded queue with blocking on overflow. | |
| template<std::size_t MaxSize> | |
| using | bounded_rejecting_queue |
| Bounded queue that rejects on overflow. | |
| template<std::size_t MaxSize> | |
| using | ring_buffer_queue |
| Bounded queue that drops oldest on overflow (ring buffer behavior) | |
| template<bool NeedExactSize, bool PreferLockFree = false> | |
| using | queue_t = typename queue_type_selector<NeedExactSize, PreferLockFree>::type |
| Convenience alias for queue type selection. | |
| using | accurate_queue_t = queue_t<true, false> |
| Queue type for accurate size/empty operations (job_queue) | |
| using | fast_queue_t = queue_t<false, true> |
| Queue type for maximum throughput (adaptive_job_queue with performance_first policy) | |
| using | balanced_queue_t = queue_t<false, false> |
| Queue type for balanced performance (adaptive_job_queue) | |
Functions | |
| std::string | error_code_to_string (error_code code) |
| Converts an error_code to a string representation. | |
| template<typename T > | |
| result< T > | optional_error_to_result (const std::optional< std::string > &error, T &&value) |
| result< void > | optional_error_to_result (const std::optional< std::string > &error) |
| std::optional< std::string > | result_to_optional_error (const result< void > &res) |
| template<typename T > | |
| std::pair< std::optional< T >, std::optional< std::string > > | result_to_pair (const result< T > &res) |
| template<typename PolicyQueueType > | |
| auto | make_policy_queue_adapter () -> std::unique_ptr< pool_queue_adapter_interface > |
| Create a pool_queue_adapter from a policy_queue type. | |
| template<typename PolicyQueueType > | |
| auto | make_policy_queue_adapter (typename PolicyQueueType::bound_policy_type bound_policy) -> std::unique_ptr< pool_queue_adapter_interface > |
| Create a pool_queue_adapter with bound policy. | |
| auto | make_standard_queue_adapter () -> std::unique_ptr< pool_queue_adapter_interface > |
| Create a standard_queue adapter. | |
| auto | make_lockfree_queue_adapter () -> std::unique_ptr< pool_queue_adapter_interface > |
| Create a lock-free queue adapter. | |
| template<typename T , typename... Args> | |
| atomic_shared_ptr< T > | make_atomic_shared (Args &&... args) |
| Make an atomic_shared_ptr with a new object. | |
| auto | pressure_level_to_string (pressure_level level) -> std::string |
| Converts pressure_level to human-readable string. | |
| auto | backpressure_policy_to_string (backpressure_policy policy) -> std::string |
| Converts backpressure_policy to human-readable string. | |
| common::error_info | to_error_info (error_code code, const std::string &message="") |
| Convert a thread::error_code to common::error_info. | |
| common::VoidResult | make_error_result (error_code code, const std::string &message="") |
| Create a common::VoidResult error from a thread::error_code. | |
| template<typename T > | |
| common::Result< T > | make_error_result (error_code code, const std::string &message="") |
| Create a common::Result<T> error from a thread::error_code. | |
| error_code | get_error_code (const common::error_info &info) |
| Extract thread::error_code from a common::error_info. | |
| const std::error_category & | thread_category () noexcept |
| Gets the singleton instance of thread_error_category. | |
| std::error_code | make_error_code (error_code e) noexcept |
| Creates a std::error_code from a thread_system error_code. | |
| std::error_condition | make_error_condition (error_code e) noexcept |
| Creates a std::error_condition from a thread_system error_code. | |
| template<typename T > | |
| pool_future< std::decay_t< T > > | make_ready_future (T &&value) |
| Create a future that is already ready with a value. | |
| pool_future< void > | make_ready_future () |
| Create a future that is already ready with void. | |
| template<typename T > | |
| pool_future< T > | make_exceptional_future (std::exception_ptr exception) |
| Create a future that is already ready with an exception. | |
| template<typename... Futures> | |
| void | wait_for_all (Futures &... futures) |
| Wait for all futures to complete. | |
| template<typename... Futures> | |
| size_t | wait_for_any (Futures &... futures) |
| Wait for any future to complete. | |
| auto | make_job () -> job_builder |
| constexpr std::string_view | to_string (log_level_v2 level) noexcept |
| Convert log_level_v2 to string representation. | |
| constexpr bool | should_log (log_level_v2 message_level, log_level_v2 min_level) noexcept |
| Check if a log level should be logged given a minimum level. | |
| log_level_v2 | parse_log_level (std::string_view str) noexcept |
| Parse string to log_level_v2. | |
| template<typename T > | |
| void | safe_retire_hazard (T *p) |
| constexpr std::string_view | to_string (thread_conditions condition) |
Converts a thread_conditions value to its corresponding string representation. | |
| auto | get_all_thread_conditions (void) -> std::vector< thread_conditions > |
Retrieves a vector containing all possible thread_conditions values. | |
| constexpr const char * | to_string (worker_state state) |
| Convert worker state to string representation. | |
| constexpr const char * | to_string (scheduling_policy policy) |
| Convert scheduling policy to string representation. | |
| constexpr const char * | to_string (steal_policy policy) |
| Convert steal policy to string representation. | |
| auto | dag_failure_policy_to_string (dag_failure_policy policy) -> std::string |
| Convert dag_failure_policy to string representation. | |
| auto | dag_job_state_to_string (dag_job_state state) -> std::string |
| Convert dag_job_state to string representation. | |
| constexpr std::string_view | to_string (job_types job_type) |
Converts a job_types value to its corresponding string representation. | |
| auto | get_all_job_types (void) -> std::vector< job_types > |
Returns a vector containing all possible job_types values. | |
| template<detail::JobType job_type = job_types> | |
| typed_thread_pool_builder< job_type > | create_pool_builder () |
| Convenience function to create a builder. | |
| constexpr const char * | to_string (enhanced_steal_policy policy) |
| Convert enhanced_steal_policy to string representation. | |
| constexpr const char * | to_string (steal_backoff_strategy strategy) |
| Convert steal_backoff_strategy to string representation. | |
| template<typename... Futures> | |
| auto | when_all (Futures &&... futures) -> std::future< std::tuple< detail::future_value_type_t< std::decay_t< Futures > >... > > |
| Wait for all futures to complete and return their results as a tuple. | |
| auto | when_all_empty () -> std::future< std::tuple<> > |
| Overload of when_all for no arguments. | |
| template<typename T > | |
| auto | when_any (std::vector< std::future< T > > &&futures) -> std::future< T > |
| Wait for any future to complete and return its result. | |
| auto | when_any (std::vector< std::future< void > > &&futures) -> std::future< void > |
| Specialization of when_any for void futures. | |
| template<typename T > | |
| auto | when_any_with_index (std::vector< std::future< T > > &&futures) -> std::future< std::pair< std::size_t, T > > |
| Wait for any future to complete with index. | |
Variables | |
| constexpr job_id | INVALID_JOB_ID = 0 |
| Invalid job ID constant. | |
| template<typename T > | |
| constexpr bool | is_sync_policy_v = detail::has_sync_policy_tag<T>::value |
| Check if type is a sync policy. | |
| template<typename T > | |
| constexpr bool | is_bound_policy_v = detail::has_bound_policy_tag<T>::value |
| Check if type is a bound policy. | |
| template<typename T > | |
| constexpr bool | is_overflow_policy_v = detail::has_overflow_policy_tag<T>::value |
| Check if type is an overflow policy. | |
| template<typename T > | |
| constexpr bool | is_policy_queue_v = detail::is_policy_queue_impl<std::remove_cv_t<T>>::value |
| Check if type is a policy_queue instantiation. | |
| template<typename T > | |
| constexpr bool | is_scheduler_v = std::is_base_of_v<scheduler_interface, std::remove_cv_t<T>> |
| Check if type is a scheduler_interface. | |
| template<typename T > | |
| constexpr bool | is_queue_capabilities_v |
| Check if type is a queue_capabilities_interface. | |
| template<typename T > | |
| constexpr bool | is_lockfree_queue_v = is_lockfree_queue<T>::value |
| template<typename T > | |
| constexpr bool | is_bounded_queue_v = is_bounded_queue<T>::value |
| template<typename T > | |
| constexpr bool | has_blocking_overflow_v = has_blocking_overflow<T>::value |
Core threading foundation of the thread system library.
Type-based thread pool implementation for job scheduling with types.
Thread pool implementation for managing worker threads.
For unified configuration, include:
The thread_module namespace provides fundamental threading primitives including the base thread class, jobs, job queues, and synchronization utilities. It serves as the foundation for all thread-related functionality in the library.
Key components include:
This namespace implements low-level threading concepts while higher-level functionality like thread pools are implemented in separate namespaces that build upon these primitives.
The thread_pool_module namespace provides a standard thread pool implementation for processing jobs concurrently using a team of worker threads.
Key components include:
The thread pool pattern improves performance by:
For unified configuration, include:
For unified configuration, include:
The kcenon::thread namespace extends the basic thread pool concept with priority-based scheduling of jobs. It allows jobs to be processed according to their importance or urgency rather than just their order of submission.
Key components include:
This implementation allows for:
| using kcenon::thread::accurate_queue_t = queue_t<true, false> |
Queue type for accurate size/empty operations (job_queue)
Definition at line 320 of file queue_factory.h.
A convenient alias for aging_typed_job_t using the job_types type.
Definition at line 171 of file aging_typed_job.h.
A convenient alias for aging_typed_job_queue_t using the job_types type.
Definition at line 404 of file aging_typed_job_queue.h.
| using kcenon::thread::balanced_queue_t = queue_t<false, false> |
Queue type for balanced performance (adaptive_job_queue)
Definition at line 327 of file queue_factory.h.
| using kcenon::thread::bounded_blocking_queue |
Bounded queue with blocking on overflow.
Definition at line 404 of file policy_queue.h.
| using kcenon::thread::bounded_rejecting_queue |
Bounded queue that rejects on overflow.
Definition at line 414 of file policy_queue.h.
Type alias for a callback_typed_job_t that uses job_types as its priority type.
Definition at line 95 of file callback_typed_job.h.
Configuration value type.
Definition at line 31 of file configuration_manager.h.
| using kcenon::thread::crash_callback = std::function<void(const crash_context&)> |
Callback function type for crash handling.
Definition at line 50 of file crash_handler.h.
| using kcenon::thread::fast_queue_t = queue_t<false, true> |
Queue type for maximum throughput (adaptive_job_queue with performance_first policy)
Definition at line 324 of file queue_factory.h.
| using kcenon::thread::ILogger = common::interfaces::ILogger |
Definition at line 25 of file thread_context.h.
| using kcenon::thread::IMonitor = common::interfaces::IMonitor |
Definition at line 28 of file thread_context.h.
| using kcenon::thread::job_id = std::uint64_t |
Adapter for lock-free queue.
Definition at line 205 of file policy_queue_adapter.h.
| typedef policy_queue< policies::lockfree_sync_policy, policies::unbounded_policy, policies::overflow_reject_policy > kcenon::thread::policy_lockfree_queue |
Lock-free unbounded queue.
Definition at line 95 of file thread_pool.h.
| using kcenon::thread::queue_t = typename queue_type_selector<NeedExactSize, PreferLockFree>::type |
Convenience alias for queue type selection.
| NeedExactSize | If true, selects job_queue |
| PreferLockFree | If true and NeedExactSize is false, selects lockfree_job_queue |
Definition at line 313 of file queue_factory.h.
| using kcenon::thread::result_t = result<T> |
Definition at line 605 of file error_handling.h.
| using kcenon::thread::ring_buffer_queue |
Bounded queue that drops oldest on overflow (ring buffer behavior)
Definition at line 424 of file policy_queue.h.
| typedef policy_queue< policies::mutex_sync_policy, policies::unbounded_policy, policies::overflow_reject_policy > kcenon::thread::standard_queue |
Standard mutex-based unbounded queue.
Definition at line 89 of file thread_pool.h.
Adapter for standard_queue (mutex-based, unbounded)
Definition at line 196 of file policy_queue_adapter.h.
A convenient alias for typed_job_t using the job_types type.
Definition at line 68 of file typed_job.h.
| using kcenon::thread::typed_job_ptr = std::shared_ptr<typed_job_interface<job_type>> |
Shared pointer type for typed job interfaces.
Definition at line 99 of file typed_job_interface.h.
| using kcenon::thread::typed_job_weak_ptr = std::weak_ptr<typed_job_interface<job_type>> |
Weak pointer type for typed job interfaces.
Definition at line 105 of file typed_job_interface.h.
Alias for a typed_thread_pool with the default job_types type.
Definition at line 470 of file typed_thread_pool.h.
Convenience typedef for a worker configured with default job_types.
Definition at line 212 of file typed_thread_worker.h.
|
strong |
Defines different aging curve algorithms.
The aging curve determines how priority boost is calculated over time.
| Enumerator | |
|---|---|
| linear | Constant boost per interval. |
| exponential | Increasing boost over time. |
| logarithmic | Decreasing boost (fast initial, slow later) |
Definition at line 52 of file priority_aging_config.h.
|
strong |
Crash safety levels for different scenarios.
| Enumerator | |
|---|---|
| minimal | |
| standard | |
| paranoid | |
Definition at line 29 of file crash_handler.h.
|
strong |
Defines how the DAG scheduler handles job failures.
Definition at line 41 of file dag_config.h.
|
strong |
State of a job in the DAG scheduler.
|
strong |
Enhanced policies for selecting work-stealing victims.
These policies extend the basic steal_policy with NUMA awareness and locality optimizations. Choose based on your workload characteristics and system architecture.
| Policy | Description | Best For |
|---|---|---|
| random | Random victim selection | General use, good load distribution |
| round_robin | Sequential selection | Deterministic, fair distribution |
| adaptive | Queue size based | Uneven workloads |
| numa_aware | Prefer same NUMA node | NUMA systems with memory locality |
| locality_aware | Prefer recently cooperated | Cache-sensitive workloads |
| hierarchical | NUMA node -> random | Large NUMA systems |
Definition at line 37 of file enhanced_steal_policy.h.
|
strong |
Strongly typed error codes for thread system operations.
Error codes are in the range [-199, -100] to comply with the central error code registry in common_system. The range is organized as:
These error codes are specific to thread_system operations and can be converted to common::error_info for use with common::Result<T> and common::VoidResult.
Error codes are in the range [-199, -100] to comply with the central error code registry in common_system. The range is organized as:
Definition at line 39 of file error_handling.h.
|
strong |
Definition at line 47 of file error_handling.h.
|
strong |
Priority levels for job scheduling.
Jobs with higher priority values are typically executed before lower priority jobs. This enum provides a standardized set of priority levels for use with composition.
|
strong |
Defines different types of jobs for a typed thread pool.
Each job in a typed thread pool can be assigned one of these types (RealTime, Batch, Background) to determine which specialized worker threads will process them. This enum uses uint8_t as its underlying type to minimize storage overhead.
| Enumerator | |
|---|---|
| RealTime | Real-time job requiring immediate response. |
| Batch | Batch processing job for throughput optimization. |
| Background | Background job for low-type maintenance tasks. |
Definition at line 32 of file job_types.h.
|
strong |
Logging severity levels (legacy).
kcenon::thread::log_level_v2 (from <kcenon/thread/core/log_level.h>) or common::interfaces::log_level (from common_system) instead. Will be removed in v2.0.0. See Issue #261 for migration details.NOTE: [[deprecated]] is applied at the thread_logger member-function level (log/set_level/log_error) rather than on this enum itself, because this type is still referenced internally by the SDOF-safe shutdown helpers. Using log_level via a deprecated API emits a warning; direct use without the logger does not.
| Enumerator | |
|---|---|
| trace | |
| debug | |
| info | |
| warning | |
| error | |
| critical | |
Definition at line 42 of file thread_logger.h.
|
strong |
Logging severity levels with explicit ascending values.
Standard ascending order (matches syslog, log4j, spdlog conventions):
This enables natural comparison: if (level >= log_level_v2::warn) { ... }
Definition at line 27 of file log_level.h.
|
strong |
Defines the strategy for calculating delay between retry attempts.
| Enumerator | |
|---|---|
| none | No retry. |
| fixed | Fixed delay between retries. |
| linear | Linearly increasing delay. |
| exponential_backoff | Exponentially increasing delay with optional jitter. |
Definition at line 28 of file retry_policy.h.
|
strong |
Scaling direction for autoscaling decisions.
| Enumerator | |
|---|---|
| none | No scaling needed. |
| up | Scale up (add workers) |
| down | Scale down (remove workers) |
Definition at line 23 of file scaling_metrics.h.
|
strong |
Reason for scaling decision.
Definition at line 33 of file scaling_metrics.h.
|
strong |
Enumeration of scheduling policies.
| Enumerator | |
|---|---|
| fifo | First-in, first-out scheduling. |
| lifo | Last-in, first-out scheduling. |
| priority | Priority-based scheduling. |
| work_stealing | Work-stealing scheduling. |
Definition at line 37 of file worker_policy.h.
|
strong |
Backoff strategies for work-stealing operations.
When a steal attempt fails, workers use backoff strategies to reduce contention and allow other threads to make progress. Different strategies offer different trade-offs between responsiveness and CPU usage.
| Strategy | Behavior | Best For |
|---|---|---|
| fixed | Constant delay | Predictable workloads |
| linear | Increasing delay | Moderate contention |
| exponential | Rapidly increasing | High contention |
| adaptive_jitter | Exponential + random | Variable workloads |
Definition at line 39 of file steal_backoff_strategy.h.
|
strong |
Policy for selecting steal victims.
When a worker's local queue is empty, it attempts to steal work from other workers. This enum defines how victims are selected.
| Enumerator | |
|---|---|
| random | Random victim selection (default, good load distribution) |
| round_robin | Sequential victim selection (deterministic, fair) |
| adaptive | Select based on queue sizes (best for uneven loads) |
Definition at line 50 of file worker_policy.h.
|
strong |
Enumeration of various states in a thread's lifecycle.
Represents distinct conditions that a thread may occupy during its execution lifecycle. This enum class is backed by uint8_t for compact storage.
| Value | Description |
|---|---|
| Created | The thread object is constructed but not yet started. |
| Waiting | The thread is started and idle, waiting for work. |
| Working | The thread is actively processing work. |
| Stopping | The thread is in the process of stopping its work. |
| Stopped | The thread has fully stopped. |
Definition at line 40 of file thread_conditions.h.
|
strong |
Enumeration of worker states.
Definition at line 25 of file worker_policy.h.
|
inlinenodiscard |
Converts backpressure_policy to human-readable string.
| policy | The policy to convert. |
Definition at line 115 of file backpressure_config.h.
References adaptive, block, callback, drop_newest, and drop_oldest.
Referenced by kcenon::thread::backpressure_job_queue::to_string().

|
nodiscard |
Convenience function to create a builder.
Definition at line 169 of file pool_builder.h.
|
inlinenodiscard |
Convert dag_failure_policy to string representation.
| policy | The policy to convert |
Definition at line 54 of file dag_config.h.
References continue_others, fail_fast, fallback, and retry.
|
inlinenodiscard |
Convert dag_job_state to string representation.
| state | The state to convert |
Definition at line 60 of file dag_job.h.
References cancelled, completed, failed, pending, ready, running, and skipped.
Referenced by kcenon::thread::dag_scheduler::to_dot(), kcenon::thread::dag_scheduler::to_json(), and kcenon::thread::dag_job::to_string().

|
inline |
Converts an error_code to a string representation.
| code | The error code to convert |
Definition at line 92 of file error_handling.h.
References condition_variable_error, deadlock_detected, file_not_found, invalid_argument, io_error, job_creation_failed, job_execution_failed, job_invalid, mutex_error, not_implemented, operation_canceled, operation_timeout, queue_busy, queue_empty, queue_full, queue_stopped, resource_allocation_failed, resource_limit_reached, success, thread_already_running, thread_join_failure, thread_not_running, thread_start_failure, and unknown_error.
Referenced by kcenon::thread::thread_error_category::message(), to_error_info(), and kcenon::thread::error::to_string().

|
inlinenodiscard |
Returns a vector containing all possible job_types values.
std::vector<job_types> with [RealTime, Batch, Background].This function is useful when iterating over all defined types (e.g. for logging, UI selection, or testing).
Definition at line 106 of file job_types.h.
References Background, Batch, and RealTime.
|
inlinenodiscard |
Retrieves a vector containing all possible thread_conditions values.
std::vector of all enumerators in thread_conditions, in ascending order.This can be useful for iteration, logging, or building UI elements that list thread states. For example:
Definition at line 108 of file thread_conditions.h.
References Created, Stopped, Stopping, Waiting, and Working.
|
inline |
Extract thread::error_code from a common::error_info.
| info | The error_info from a common::Result or common::VoidResult |
Example:
Definition at line 220 of file error_handling.h.
References info.
|
nodiscard |
Make an atomic_shared_ptr with a new object.
| T | Object type |
| Args | Constructor argument types |
| args | Constructor arguments |
Definition at line 283 of file atomic_shared_ptr.h.
|
inlinenoexcept |
Creates a std::error_code from a thread_system error_code.
| e | The thread_system error_code |
Definition at line 290 of file error_handling.h.
References thread_category().

|
inlinenoexcept |
Creates a std::error_condition from a thread_system error_code.
| e | The thread_system error_code |
Definition at line 299 of file error_handling.h.
References thread_category().

|
inline |
Create a common::VoidResult error from a thread::error_code.
| code | The thread-specific error code |
| message | Optional additional message |
Example:
Definition at line 178 of file error_handling.h.
References to_error_info().
Referenced by kcenon::thread::dag_scheduler::add_dependency(), kcenon::thread::backpressure_job_queue::apply_backpressure(), kcenon::thread::cancellation_token::check_cancelled(), kcenon::thread::enhanced_cancellation_token::check_cancelled(), kcenon::thread::dag_job::do_work(), kcenon::thread::future_job< R >::do_work(), kcenon::thread::job_builder::built_job::do_work(), kcenon::thread::protected_job::do_work(), kcenon::thread::backpressure_job_queue::enqueue(), kcenon::thread::backpressure_job_queue::enqueue_batch(), kcenon::thread::dag_scheduler::execute(), kcenon::thread::dag_scheduler::execute_all(), kcenon::thread::dag_scheduler::execute_job(), kcenon::thread::cancellable_future< R >::get(), kcenon::thread::cancellable_future< void >::get(), kcenon::thread::cancellable_future< R >::get_for(), kcenon::thread::cancellable_future< void >::get_for(), kcenon::thread::backpressure_job_queue::handle_adaptive_policy(), kcenon::thread::backpressure_job_queue::handle_block_policy(), kcenon::thread::backpressure_job_queue::handle_callback_policy(), kcenon::thread::circuit_breaker_policy::on_enqueue(), kcenon::thread::dag_scheduler::remove_job(), kcenon::thread::dag_scheduler::reset(), and kcenon::thread::thread_pool::submit_wait_any().


| common::Result< T > kcenon::thread::make_error_result | ( | error_code | code, |
| const std::string & | message = "" ) |
Create a common::Result<T> error from a thread::error_code.
| T | The value type of the result |
| code | The thread-specific error code |
| message | Optional additional message |
Example:
Definition at line 200 of file error_handling.h.
References to_error_info().

| pool_future< T > kcenon::thread::make_exceptional_future | ( | std::exception_ptr | exception | ) |
Create a future that is already ready with an exception.
Definition at line 201 of file future_extensions.h.
References kcenon::thread::pool_promise< T >::get_future(), and kcenon::thread::pool_promise< T >::set_exception().

|
inlinenodiscard |
Definition at line 432 of file job_builder.h.
|
inlinenodiscard |
Create a lock-free queue adapter.
Definition at line 269 of file policy_queue_adapter.h.
|
nodiscard |
Create a pool_queue_adapter from a policy_queue type.
| PolicyQueueType | A policy_queue instantiation |
Definition at line 225 of file policy_queue_adapter.h.
|
nodiscard |
Create a pool_queue_adapter with bound policy.
| PolicyQueueType | A policy_queue instantiation |
| bound_policy | Bound policy configuration |
Definition at line 243 of file policy_queue_adapter.h.
|
inline |
Create a future that is already ready with void.
Definition at line 190 of file future_extensions.h.
References kcenon::thread::pool_promise< T >::get_future(), and kcenon::thread::pool_promise< T >::set_value().

| pool_future< std::decay_t< T > > kcenon::thread::make_ready_future | ( | T && | value | ) |
Create a future that is already ready with a value.
Definition at line 180 of file future_extensions.h.
References kcenon::thread::pool_promise< T >::get_future(), and kcenon::thread::pool_promise< T >::set_value().

|
inlinenodiscard |
Create a standard_queue adapter.
Definition at line 259 of file policy_queue_adapter.h.
|
inline |
Definition at line 617 of file error_handling.h.
References unknown_error.
| result< T > kcenon::thread::optional_error_to_result | ( | const std::optional< std::string > & | error, |
| T && | value ) |
Definition at line 609 of file error_handling.h.
References unknown_error.
|
inlinenoexcept |
Parse string to log_level_v2.
Definition at line 75 of file log_level.h.
References critical, debug, error, info, off, trace, and warn.
|
inlinenodiscard |
Converts pressure_level to human-readable string.
| level | The pressure level to convert. |
Definition at line 98 of file backpressure_config.h.
References critical, high, low, and none.
Referenced by kcenon::thread::backpressure_job_queue::to_string().

|
inline |
Definition at line 625 of file error_handling.h.
References kcenon::thread::result< T >::get_error(), and kcenon::thread::error::to_string().

| std::pair< std::optional< T >, std::optional< std::string > > kcenon::thread::result_to_pair | ( | const result< T > & | res | ) |
Definition at line 633 of file error_handling.h.
References kcenon::thread::result< T >::get_error(), kcenon::thread::error::to_string(), and kcenon::thread::result< T >::value().

| void kcenon::thread::safe_retire_hazard | ( | T * | p | ) |
Definition at line 460 of file safe_hazard_pointer.h.
References kcenon::thread::safe_hazard_pointer_domain::instance(), and kcenon::thread::safe_hazard_pointer_domain::retire().
Referenced by kcenon::thread::typed_safe_hazard_domain< T >::retire().


|
constexprnoexcept |
Check if a log level should be logged given a minimum level.
With ascending order, we log if message_level >= min_level
Definition at line 65 of file log_level.h.
References off.
|
inlinenoexcept |
Gets the singleton instance of thread_error_category.
Definition at line 280 of file error_handling.h.
Referenced by make_error_code(), and make_error_condition().

|
inline |
Convert a thread::error_code to common::error_info.
| code | The thread-specific error code |
| message | Optional additional message (defaults to error_code_to_string) |
Example:
Definition at line 156 of file error_handling.h.
References error_code_to_string().
Referenced by make_error_result(), and kcenon::thread::dag_scheduler::on_job_failed().


|
constexpr |
Convert enhanced_steal_policy to string representation.
| policy | The policy to convert |
Definition at line 52 of file enhanced_steal_policy.h.
References adaptive, hierarchical, locality_aware, numa_aware, random, and round_robin.
|
nodiscardconstexpr |
Converts a job_types value to its corresponding string representation.
| job_type | The job_types value to convert. |
std::string_view containing one of "REALTIME", "BATCH", "BACKGROUND", or "UNKNOWN" if job_type is out of expected range.Definition at line 81 of file job_types.h.
References kcenon::thread::job_detail::job_type_count, and kcenon::thread::job_detail::job_type_strings.
|
constexprnoexcept |
Convert log_level_v2 to string representation.
Definition at line 40 of file log_level.h.
References critical, debug, error, info, off, trace, and warn.
Referenced by std::formatter< kcenon::thread::job_types >::format(), std::formatter< kcenon::thread::job_types, wchar_t >::format(), std::formatter< kcenon::thread::thread_conditions >::format(), and std::formatter< kcenon::thread::thread_conditions, wchar_t >::format().

|
constexpr |
Convert scheduling policy to string representation.
Definition at line 153 of file worker_policy.h.
References fifo, lifo, priority, and work_stealing.
|
constexpr |
Convert steal_backoff_strategy to string representation.
| strategy | The strategy to convert |
Definition at line 224 of file steal_backoff_strategy.h.
References adaptive_jitter, exponential, fixed, and linear.
|
constexpr |
Convert steal policy to string representation.
Definition at line 166 of file worker_policy.h.
References adaptive, random, and round_robin.
|
nodiscardconstexpr |
Converts a thread_conditions value to its corresponding string representation.
| condition | The thread_conditions value to convert. |
std::string_view representing the condition name. If the value is out of range, returns "UNKNOWN".Example:
Definition at line 88 of file thread_conditions.h.
References kcenon::thread::job_detail::thread_conditions_count, and kcenon::thread::job_detail::thread_conditions_strings.
|
constexpr |
Convert worker state to string representation.
Definition at line 138 of file worker_policy.h.
References active, created, idle, starting, stopped, and stopping.
| void kcenon::thread::wait_for_all | ( | Futures &... | futures | ) |
Wait for all futures to complete.
Definition at line 212 of file future_extensions.h.
| size_t kcenon::thread::wait_for_any | ( | Futures &... | futures | ) |
Wait for any future to complete.
Definition at line 220 of file future_extensions.h.
| auto kcenon::thread::when_all | ( | Futures &&... | futures | ) | -> std::future<std::tuple<detail::future_value_type_t<std::decay_t<Futures>>...>> |
Wait for all futures to complete and return their results as a tuple.
| Futures | Variadic future types |
| futures | The futures to wait on |
This function creates a new future that completes when all input futures complete. The result is a tuple containing the values from each future.
Definition at line 78 of file when_helpers.h.
References kcenon::thread::detail::get_all_impl().

|
inline |
Overload of when_all for no arguments.
Definition at line 110 of file when_helpers.h.
| auto kcenon::thread::when_any | ( | std::vector< std::future< T > > && | futures | ) | -> std::future<T> |
Wait for any future to complete and return its result.
| T | The common result type of all futures |
| futures | Vector of futures |
This function creates a new future that completes when any of the input futures completes. The result is the value from the first completed future.
Definition at line 141 of file when_helpers.h.
References completed.
|
inline |
Specialization of when_any for void futures.
Definition at line 183 of file when_helpers.h.
References completed.
| auto kcenon::thread::when_any_with_index | ( | std::vector< std::future< T > > && | futures | ) | -> std::future<std::pair<std::size_t, T>> |
Wait for any future to complete with index.
| T | The common result type of all futures |
| futures | Vector of futures |
Similar to when_any, but also returns the index of which future completed first.
Definition at line 240 of file when_helpers.h.
References completed.
|
constexpr |
Definition at line 266 of file queue_traits.h.
|
constexpr |
Invalid job ID constant.
Definition at line 38 of file dag_job.h.
Referenced by kcenon::thread::dag_job::add_dependency(), kcenon::thread::dag_scheduler::add_job(), kcenon::thread::dag_job_builder::depends_on(), kcenon::thread::dag_job_builder::depends_on(), and kcenon::thread::dag_job_builder::depends_on().
|
constexpr |
Check if type is a bound policy.
Definition at line 82 of file queue_traits.h.
Referenced by kcenon::thread::queue_factory::create_custom_policy_queue().
|
constexpr |
Definition at line 250 of file queue_traits.h.
|
constexpr |
Definition at line 232 of file queue_traits.h.
|
constexpr |
Check if type is an overflow policy.
Definition at line 88 of file queue_traits.h.
Referenced by kcenon::thread::queue_factory::create_custom_policy_queue().
|
constexpr |
Check if type is a policy_queue instantiation.
This trait identifies whether a type is an instantiation of the policy_queue template, allowing compile-time branching based on queue type.
Definition at line 159 of file queue_traits.h.
|
constexpr |
Check if type is a queue_capabilities_interface.
Definition at line 173 of file queue_traits.h.
|
constexpr |
Check if type is a scheduler_interface.
Detects whether a type inherits from scheduler_interface.
Definition at line 167 of file queue_traits.h.
|
constexpr |
Check if type is a sync policy.
Definition at line 76 of file queue_traits.h.
Referenced by kcenon::thread::queue_factory::create_custom_policy_queue().