|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Information about a worker thread in the pool. More...
#include <thread_info.h>

Public Member Functions | |
| auto | state_duration () const -> std::chrono::nanoseconds |
| Calculates the duration in the current state. | |
| auto | total_jobs () const -> std::uint64_t |
| Gets the total number of jobs processed (completed + failed). | |
| auto | success_rate () const -> double |
| Calculates the success rate. | |
| auto | is_busy () const -> bool |
| Checks if the worker is currently processing a job. | |
| auto | is_available () const -> bool |
| Checks if the worker is available to process jobs. | |
| auto | update_utilization () -> void |
| Recalculates utilization based on busy and idle times. | |
| auto | busy_time_ms () const -> double |
| Converts busy time to milliseconds. | |
| auto | idle_time_ms () const -> double |
| Converts idle time to milliseconds. | |
| auto | to_json () const -> std::string |
| Converts the thread info to a JSON string. | |
| auto | to_string () const -> std::string |
| Converts the thread info to a human-readable string. | |
Public Attributes | |
| std::thread::id | thread_id |
| System thread ID. | |
| std::string | thread_name |
| Human-readable name for this thread. | |
| std::size_t | worker_id {0} |
| Worker ID within the pool. | |
| worker_state | state {worker_state::idle} |
| Current operational state of the worker. | |
| std::chrono::steady_clock::time_point | state_since |
| Time when the worker entered its current state. | |
| std::optional< job_info > | current_job |
| Information about the currently executing job. | |
| std::uint64_t | jobs_completed {0} |
| Total number of jobs successfully completed by this worker. | |
| std::uint64_t | jobs_failed {0} |
| Total number of jobs that failed during execution. | |
| std::chrono::nanoseconds | total_busy_time {0} |
| Total time spent executing jobs (busy time). | |
| std::chrono::nanoseconds | total_idle_time {0} |
| Total time spent waiting for jobs (idle time). | |
| double | utilization {0.0} |
| Worker utilization ratio. | |
Information about a worker thread in the pool.
Contains comprehensive information about a worker thread including its identity, current state, statistics, and optionally the job it is currently processing.
Definition at line 87 of file thread_info.h.
|
inlinenodiscard |
Converts busy time to milliseconds.
Definition at line 239 of file thread_info.h.
References total_busy_time.
Referenced by to_json().

|
inlinenodiscard |
Converts idle time to milliseconds.
Definition at line 248 of file thread_info.h.
References total_idle_time.
Referenced by to_json().

|
inlinenodiscard |
Checks if the worker is available to process jobs.
Definition at line 210 of file thread_info.h.
References kcenon::thread::diagnostics::idle, and state.
|
inlinenodiscard |
Checks if the worker is currently processing a job.
Definition at line 201 of file thread_info.h.
References kcenon::thread::diagnostics::active, and state.
|
inlinenodiscard |
Calculates the duration in the current state.
Definition at line 169 of file thread_info.h.
References state_since.
Referenced by to_json(), and to_string().

|
inlinenodiscard |
Calculates the success rate.
Definition at line 187 of file thread_info.h.
References jobs_completed, and total_jobs().
Referenced by to_json(), and to_string().


|
inlinenodiscard |
Converts the thread info to a JSON string.
Output format:
Definition at line 275 of file thread_info.h.
References busy_time_ms(), current_job, idle_time_ms(), jobs_completed, jobs_failed, state, state_duration(), success_rate(), thread_id, thread_name, utilization, worker_id, and kcenon::thread::diagnostics::worker_state_to_string().

|
inlinenodiscard |
Converts the thread info to a human-readable string.
Output format:
Definition at line 325 of file thread_info.h.
References current_job, jobs_completed, jobs_failed, state, state_duration(), success_rate(), thread_id, thread_name, utilization, and kcenon::thread::diagnostics::worker_state_to_string().

|
inlinenodiscard |
Gets the total number of jobs processed (completed + failed).
Definition at line 178 of file thread_info.h.
References jobs_completed, and jobs_failed.
Referenced by success_rate().

|
inline |
Recalculates utilization based on busy and idle times.
Updates the utilization field based on current total_busy_time and total_idle_time values.
Definition at line 221 of file thread_info.h.
References total_busy_time, total_idle_time, and utilization.
| std::optional<job_info> kcenon::thread::diagnostics::thread_info::current_job |
Information about the currently executing job.
Only has a value if state == active.
Definition at line 127 of file thread_info.h.
Referenced by to_json(), and to_string().
| std::uint64_t kcenon::thread::diagnostics::thread_info::jobs_completed {0} |
Total number of jobs successfully completed by this worker.
Definition at line 136 of file thread_info.h.
Referenced by success_rate(), to_json(), to_string(), and total_jobs().
| std::uint64_t kcenon::thread::diagnostics::thread_info::jobs_failed {0} |
Total number of jobs that failed during execution.
Definition at line 141 of file thread_info.h.
Referenced by to_json(), to_string(), and total_jobs().
| worker_state kcenon::thread::diagnostics::thread_info::state {worker_state::idle} |
Current operational state of the worker.
Definition at line 113 of file thread_info.h.
Referenced by is_available(), is_busy(), to_json(), and to_string().
| std::chrono::steady_clock::time_point kcenon::thread::diagnostics::thread_info::state_since |
Time when the worker entered its current state.
Used to calculate how long the worker has been in its current state.
Definition at line 120 of file thread_info.h.
Referenced by state_duration().
| std::thread::id kcenon::thread::diagnostics::thread_info::thread_id |
System thread ID.
The native thread identifier from the operating system.
Definition at line 94 of file thread_info.h.
Referenced by to_json(), and to_string().
| std::string kcenon::thread::diagnostics::thread_info::thread_name |
Human-readable name for this thread.
Typically in the format "Worker-N" where N is the worker index.
Definition at line 101 of file thread_info.h.
Referenced by to_json(), and to_string().
| std::chrono::nanoseconds kcenon::thread::diagnostics::thread_info::total_busy_time {0} |
Total time spent executing jobs (busy time).
Definition at line 146 of file thread_info.h.
Referenced by busy_time_ms(), and update_utilization().
| std::chrono::nanoseconds kcenon::thread::diagnostics::thread_info::total_idle_time {0} |
Total time spent waiting for jobs (idle time).
Definition at line 151 of file thread_info.h.
Referenced by idle_time_ms(), and update_utilization().
| double kcenon::thread::diagnostics::thread_info::utilization {0.0} |
Worker utilization ratio.
Calculated as: total_busy_time / (total_busy_time + total_idle_time). Value ranges from 0.0 (never busy) to 1.0 (always busy).
Definition at line 159 of file thread_info.h.
Referenced by to_json(), to_string(), and update_utilization().
| std::size_t kcenon::thread::diagnostics::thread_info::worker_id {0} |
Worker ID within the pool.
Unique identifier for this worker, assigned by the pool.
Definition at line 108 of file thread_info.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::get_worker_info(), and to_json().