|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Context object that provides access to optional services. More...
#include <thread_context.h>

Public Member Functions | |
| thread_context () | |
| Default constructor - resolves services from global registry. | |
| thread_context (std::shared_ptr< ILogger > logger, std::shared_ptr< IMonitor > monitoring=nullptr) | |
| Constructor with explicit service injection. | |
| std::shared_ptr< ILogger > | logger () const |
| Get the logger service. | |
| std::shared_ptr< IMonitor > | monitoring () const |
| Get the monitoring service. | |
| void | log (common::interfaces::log_level level, const std::string &message) const |
| Log a message if logger is available. | |
| void | log (log_level_v2 level, const std::string &message) const |
| Log a message if logger is available (v2 API with conversion) | |
| void | log (common::interfaces::log_level level, std::string_view message, const common::source_location &loc=common::source_location::current()) const |
| Log a message with source location if logger is available. | |
| void | update_system_metrics (const common::interfaces::system_metrics &metrics) const |
| Update system metrics if monitoring is available. | |
| void | update_thread_pool_metrics (const common::interfaces::thread_pool_metrics &metrics) const |
| Update thread pool metrics if monitoring is available. | |
| void | update_thread_pool_metrics (const std::string &pool_name, std::uint32_t pool_instance_id, const common::interfaces::thread_pool_metrics &metrics) const |
| Update thread pool metrics with pool identifier. | |
| void | update_worker_metrics (std::size_t worker_id, const common::interfaces::worker_metrics &metrics) const |
| Update worker metrics if monitoring is available. | |
| thread_context | create_child () const |
| Create a child context with the same services. | |
| auto | get_context_name () const -> std::string |
| Get context name. | |
| auto | set_context_name (const std::string &name) -> bool |
| Set context name. | |
| auto | has_logger () const -> bool |
| Check if logger is available. | |
| auto | has_monitoring () const -> bool |
| Check if monitoring is available. | |
Static Private Member Functions | |
| static common::interfaces::log_level | to_common_level (log_level_v2 level) |
| Convert log_level_v2 to common::interfaces::log_level. | |
Private Attributes | |
| std::shared_ptr< ILogger > | logger_ |
| std::shared_ptr< IMonitor > | monitoring_ |
| std::string | context_name_ |
Context object that provides access to optional services.
This class uses composition to provide thread system components with optional access to logger and monitoring services.
Definition at line 40 of file thread_context.h.
|
inline |
Default constructor - resolves services from global registry.
Definition at line 45 of file thread_context.h.
Referenced by create_child().

|
inlineexplicit |
Constructor with explicit service injection.
| logger | Optional logger service (ILogger from common_system) |
| monitoring | Optional monitoring service (IMonitor from common_system) |
Definition at line 55 of file thread_context.h.
|
inline |
Create a child context with the same services.
Definition at line 244 of file thread_context.h.
References logger_, monitoring_, and thread_context().

|
inline |
Get context name.
Definition at line 252 of file thread_context.h.
References context_name_.
|
inline |
Check if logger is available.
Definition at line 270 of file thread_context.h.
References logger_.
|
inline |
Check if monitoring is available.
Definition at line 278 of file thread_context.h.
References monitoring_.
|
inline |
Log a message if logger is available.
| level | Log level (common::interfaces::log_level) |
| message | Log message |
Definition at line 86 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and logger_.

|
inline |
Log a message with source location if logger is available.
| level | Log level (common::interfaces::log_level) |
| message | Log message |
| loc | Source location (automatically captured) |
Definition at line 123 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and logger_.

|
inline |
Log a message if logger is available (v2 API with conversion)
| level | Log level (log_level_v2 with ascending order) |
| message | Log message |
Definition at line 104 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), logger_, and to_common_level().

|
inline |
Get the logger service.
Definition at line 66 of file thread_context.h.
References logger_.
|
inline |
Get the monitoring service.
Definition at line 74 of file thread_context.h.
References monitoring_.
Referenced by kcenon::thread::thread_pool::report_metrics(), kcenon::thread::thread_pool::thread_pool(), kcenon::thread::thread_pool::thread_pool(), and kcenon::thread::thread_pool::thread_pool().

|
inline |
Set context name.
| name | New context name |
Definition at line 261 of file thread_context.h.
References context_name_.
|
inlinestaticprivate |
Convert log_level_v2 to common::interfaces::log_level.
Definition at line 290 of file thread_context.h.
References kcenon::thread::critical, kcenon::thread::debug, kcenon::thread::error, kcenon::thread::info, kcenon::thread::off, kcenon::thread::trace, and kcenon::thread::warn.
Referenced by log().

|
inline |
Update system metrics if monitoring is available.
| metrics | System metrics to record |
Definition at line 142 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and monitoring_.

|
inline |
Update thread pool metrics if monitoring is available.
| metrics | Thread pool metrics to record |
Definition at line 163 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and monitoring_.
Referenced by kcenon::thread::thread_pool::report_metrics().


|
inline |
Update thread pool metrics with pool identifier.
| pool_name | Name of the thread pool |
| pool_instance_id | Instance ID for multiple pools |
| metrics | Thread pool metrics to record |
Definition at line 192 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and monitoring_.

|
inline |
Update worker metrics if monitoring is available.
| worker_id | Worker identifier |
| metrics | Worker metrics to record |
Definition at line 222 of file thread_context.h.
References kcenon::thread::thread_logger::is_shutting_down(), and monitoring_.

|
mutableprivate |
Definition at line 285 of file thread_context.h.
Referenced by get_context_name(), and set_context_name().
|
private |
Definition at line 283 of file thread_context.h.
Referenced by create_child(), has_logger(), log(), log(), log(), and logger().
|
private |
Definition at line 284 of file thread_context.h.
Referenced by create_child(), has_monitoring(), monitoring(), update_system_metrics(), update_thread_pool_metrics(), update_thread_pool_metrics(), and update_worker_metrics().