Loading...
Searching...
No Matches
Thread-safe progress reporter for staged map work.
More...
#include <map_progress.h>
|
| | MapProgress (std::string label="Map progress") |
| | Start reporting progress under a human-readable label.
|
| | ~MapProgress () |
| | Signal the reporter to emit its final status, then join it.
|
| void | stage (const std::string &name, double first, double last, double estimateSeconds=0) |
| | Begin a monotonic percentage range for one named stage.
|
| void | update (double fraction, const std::string &detail={}) |
| | Advance the current stage without allowing its fraction to regress.
|
| void | detail (const std::string &text) |
| | Replace the operator-facing detail without changing progress.
|
| void | finish () |
| | Mark the entire operation complete and permit 100 percent output.
|
|
| static void | selfTest () |
| | Exercise stage progress, monotonic updates, and completion behavior.
|
|
| using | Clock = std::chrono::steady_clock |
|
| void | stageTiming (Clock::time_point now, const char *status) |
| | Emit at most one elapsed-time record for the active timed stage.
|
| double | percentage (Clock::time_point now) const |
| | Estimate overall progress from reported work and stage time.
|
| std::string | line (Clock::time_point now) const |
| | Format a consistent progress snapshot under the state mutex.
|
| void | report () |
| | Run the progress reporter until teardown.
|
|
| static std::string | duration (Clock::duration value) |
| | Format an elapsed duration at whole-second precision.
|
Thread-safe progress reporter for staged map work.
A reporter thread emits a heartbeat even when a computation has no fine-grained updates. Destruction joins that thread and reports interruption unless finish was called.
Definition at line 49 of file map_progress.h.
◆ Clock
◆ MapProgress()
| pangea_survey::MapProgress::MapProgress |
( |
std::string | label = "Map progress" | ) |
|
|
inlineexplicit |
Start reporting progress under a human-readable label.
- Parameters
-
| [in] | label | Prefix shown on each progress line. |
Definition at line 131 of file map_progress.h.
◆ ~MapProgress()
| pangea_survey::MapProgress::~MapProgress |
( |
| ) |
|
|
inline |
Signal the reporter to emit its final status, then join it.
Drop the state mutex before joining so the reporter can exit.
Definition at line 135 of file map_progress.h.
◆ detail()
| void pangea_survey::MapProgress::detail |
( |
const std::string & | text | ) |
|
|
inline |
Replace the operator-facing detail without changing progress.
Definition at line 181 of file map_progress.h.
◆ duration()
| std::string pangea_survey::MapProgress::duration |
( |
Clock::duration | value | ) |
|
|
inlinestaticprivate |
Format an elapsed duration at whole-second precision.
- Parameters
-
| value | Nonnegative interval. |
- Returns
- Hours, minutes and seconds without wrapping hours at a day.
Definition at line 89 of file map_progress.h.
◆ finish()
| void pangea_survey::MapProgress::finish |
( |
| ) |
|
|
inline |
Mark the entire operation complete and permit 100 percent output.
Definition at line 186 of file map_progress.h.
◆ line()
| std::string pangea_survey::MapProgress::line |
( |
Clock::time_point | now | ) |
const |
|
inlineprivate |
Format a consistent progress snapshot under the state mutex.
- Parameters
-
| now | Monotonic time shared by all elapsed fields on the line. |
- Returns
- Complete line including its newline.
Distinguish an interrupted shutdown from completed publication.
Definition at line 100 of file map_progress.h.
◆ percentage()
| double pangea_survey::MapProgress::percentage |
( |
Clock::time_point | now | ) |
const |
|
inlineprivate |
Estimate overall progress from reported work and stage time.
- Parameters
-
| now | Current monotonic time. |
- Returns
- Estimated percentage; 100 is reserved for explicit completion.
The time estimate approaches the stage endpoint without claiming all its work is done. Prefer measured progress when greater.
Definition at line 81 of file map_progress.h.
◆ report()
| void pangea_survey::MapProgress::report |
( |
| ) |
|
|
inlineprivate |
Run the progress reporter until teardown.
Wake on changes or every five seconds so a long stage remains observable. Emit a last snapshot even when stopped early.
Definition at line 113 of file map_progress.h.
◆ selfTest()
| void pangea_survey::MapProgress::selfTest |
( |
| ) |
|
|
inlinestatic |
Exercise stage progress, monotonic updates, and completion behavior.
- Exceptions
-
| std::runtime_error | If a progress invariant fails. |
Sample estimated progress at fixed synthetic offsets instead of waiting for a long stage in real time.
Definition at line 198 of file map_progress.h.
◆ stage()
| void pangea_survey::MapProgress::stage |
( |
const std::string & | name, |
|
|
double | first, |
|
|
double | last, |
|
|
double | estimateSeconds = 0 ) |
|
inline |
Begin a monotonic percentage range for one named stage.
- Parameters
-
| [in] | name | Stage label. |
| [in] | first | First percentage assigned to the stage. |
| [in] | last | Upper percentage bound, at most 99.9 until finish. |
| [in] | estimateSeconds | Optional duration used only for a bounded estimate. |
- Exceptions
-
| std::runtime_error | If bounds are invalid or progress would move backward. |
Definition at line 152 of file map_progress.h.
◆ stageTiming()
| void pangea_survey::MapProgress::stageTiming |
( |
Clock::time_point | now, |
|
|
const char * | status ) |
|
inlineprivate |
Emit at most one elapsed-time record for the active timed stage.
- Parameters
-
| now | Current monotonic time. |
| status | Terminal stage label. |
Disarm reporting after emission so teardown cannot repeat it.
Definition at line 64 of file map_progress.h.
◆ update()
| void pangea_survey::MapProgress::update |
( |
double | fraction, |
|
|
const std::string & | detail = {} ) |
|
inline |
Advance the current stage without allowing its fraction to regress.
- Parameters
-
| [in] | fraction | Stage completion estimate in the closed interval [0, 1]. |
| [in] | detail | Optional current item or count shown to the operator. |
- Exceptions
-
| std::runtime_error | If fraction is nonfinite or outside [0, 1]. |
Definition at line 173 of file map_progress.h.
◆ changed_
| bool pangea_survey::MapProgress::changed_ = true |
|
private |
◆ closing_
| bool pangea_survey::MapProgress::closing_ = false |
|
private |
◆ complete_
| bool pangea_survey::MapProgress::complete_ = false |
|
private |
◆ detail_
| std::string pangea_survey::MapProgress::detail_ |
|
private |
◆ estimateSeconds_
| double pangea_survey::MapProgress::estimateSeconds_ = 0 |
|
private |
◆ first_
| double pangea_survey::MapProgress::first_ = 0 |
|
private |
◆ fraction_
| double pangea_survey::MapProgress::fraction_ = 0 |
|
private |
◆ label_
| std::string pangea_survey::MapProgress::label_ |
|
private |
◆ last_
| double pangea_survey::MapProgress::last_ = 0 |
|
private |
◆ mutex_
| std::mutex pangea_survey::MapProgress::mutex_ |
|
private |
◆ reporter_
| std::thread pangea_survey::MapProgress::reporter_ |
|
private |
◆ stage_
| std::string pangea_survey::MapProgress::stage_ = "Preparing" |
|
private |
◆ stageStarted_
| Clock::time_point pangea_survey::MapProgress::stageStarted_ = started_ |
|
private |
◆ started_
| Clock::time_point pangea_survey::MapProgress::started_ = Clock::now() |
|
private |
◆ timedStage_
| bool pangea_survey::MapProgress::timedStage_ = false |
|
private |
◆ wake_
| std::condition_variable pangea_survey::MapProgress::wake_ |
|
private |
The documentation for this class was generated from the following file: