Thread-safe tracker for monitoring the progress of a job composed of multiple steps.
More...
#include <progress_tracker.hpp>
Thread-safe tracker for monitoring the progress of a job composed of multiple steps.
◆ progress_tracker()
recognition::utility::progress_tracker::progress_tracker |
( |
std::uint64_t | total_steps = 1u | ) |
|
|
inlineexplicitnoexcept |
Construct progress_tracker with a given total number of steps.
- Parameters
-
total_steps | Total number of steps (must be >= 1). Defaults to 1. |
◆ advance()
void recognition::utility::progress_tracker::advance |
( |
std::uint64_t | step_count = 1u | ) |
|
|
inlinenoexcept |
Increments the number of completed steps.
- Parameters
-
step_count | Number of steps to mark as completed. Defaults to 1. |
◆ get_completed_steps()
std::uint64_t recognition::utility::progress_tracker::get_completed_steps |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- The number of completed steps.
◆ get_completion_percentage()
percentage recognition::utility::progress_tracker::get_completion_percentage |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- The completion percentage of the job.
◆ get_incompleted_steps()
std::uint64_t recognition::utility::progress_tracker::get_incompleted_steps |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- The number of steps that are yet to be completed.
◆ get_total_steps()
std::uint64_t recognition::utility::progress_tracker::get_total_steps |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- The total number of steps.
◆ is_completed()
bool recognition::utility::progress_tracker::is_completed |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- True if the job has completed all steps, false otherwise.
◆ mark_as_completed()
void recognition::utility::progress_tracker::mark_as_completed |
( |
| ) |
|
|
inlinenoexcept |
Marks the job as fully completed.
◆ reset()
void recognition::utility::progress_tracker::reset |
( |
std::uint64_t | total_steps | ) |
|
|
inlinenoexcept |
Reset the tracker with a new total step count.
- Parameters
-
total_steps | New total number of steps (must be >= 1). |
◆ try_wait_for_completion()
template<typename RepresentationType , typename PeriodType >
bool recognition::utility::progress_tracker::try_wait_for_completion |
( |
std::chrono::duration< RepresentationType, PeriodType > | timeout | ) |
const |
|
inlinenodiscard |
Wait for the job to complete, or until the specified timeout duration elapses.
- Template Parameters
-
RepresentationType | A representation type for the duration. |
PeriodType | A ratio type representing the duration's tick period. |
- Parameters
-
timeout | Maximum duration to wait. |
- Returns
- True if the job completed before the timeout, false otherwise.
◆ try_wait_for_completion_until()
template<typename ClockType , typename DurationType >
bool recognition::utility::progress_tracker::try_wait_for_completion_until |
( |
std::chrono::time_point< ClockType, DurationType > | deadline | ) |
const |
|
inlinenodiscard |
Wait until the job is complete or the specified deadline is reached.
- Template Parameters
-
ClockType | A clock type used for time points. |
DurationType | A duration type representing the clock's precision or resolution. |
- Parameters
-
deadline | The absolute time point to wait until. |
- Returns
- True if the job completed before the deadline, false otherwise.
◆ wait_for_completion()
void recognition::utility::progress_tracker::wait_for_completion |
( |
| ) |
const |
|
inline |
Wait until all steps are completed.
◆ m_completed_steps
std::uint64_t recognition::utility::progress_tracker::m_completed_steps {0u} |
|
private |
◆ m_condition_variable
std::condition_variable recognition::utility::progress_tracker::m_condition_variable {} |
|
mutableprivate |
◆ m_mutex
std::mutex recognition::utility::progress_tracker::m_mutex {} |
|
mutableprivate |
◆ m_total_steps
std::uint64_t recognition::utility::progress_tracker::m_total_steps |
|
private |
The documentation for this class was generated from the following file: