Regina Calculation Engine
|
Manages percentage-based progress tracking and cancellation polling for long operations. More...
#include <progress/progresstracker.h>
Public Member Functions | |
ProgressTracker () | |
Creates a new progress tracker. More... | |
bool | percentChanged () |
Queries whether the percentage progress has changed since the last call to percentChanged(). More... | |
double | percent () |
Returns the percentage progress through the entire operation. More... | |
void | newStage (const char *desc, double weight=1) |
Used by the writing thread to indicate that it has moved on to a new stage of processing. More... | |
void | newStage (const std::string &desc, double weight=1) |
Used by the writing thread to indicate that it has moved on to a new stage of processing. More... | |
bool | setPercent (double percent) |
Used by the writing thread to indicate the level of progress through the current stage. More... | |
void | setFinished () |
Used by the writing thread to indicate that it has finished all processing. More... | |
bool | isFinished () |
Queries whether the writing thread has finished all processing. More... | |
bool | descriptionChanged () |
Queries whether the stage description has changed since the last call to descriptionChanged(). More... | |
std::string | description () |
Returns the human-readable description of the current stage. More... | |
void | cancel () |
Indicates to the writing thread that the user wishes to cancel the operation. More... | |
bool | isCancelled () |
Queries whether the reading thread has made a request for the writing thread to cancel the operation; in other words, whether cancel() has been called. More... | |
Protected Attributes | |
std::string | desc_ |
The human-readable description of the current stage. More... | |
bool | descChanged_ |
Has the description changed since the last call to descriptionChanged()? More... | |
bool | cancelled_ |
Has the reading thread requested that the operation be cancelled? More... | |
bool | finished_ |
Has the writing thread declared that it has finished all processing? More... | |
std::mutex | lock_ |
A mutex to stop the reading and writing threads from interfering with each other. More... | |
Manages percentage-based progress tracking and cancellation polling for long operations.
See the ProgressTrackerBase documentation for detailed information on how to use a progress tracker.
This class represents a progress tracker that measures progress using percentages. Specifically, each stage has a percentage progress that rises from 0 to 100 as the stage progresses. Each stage also has a fractional weight (between 0 and 1 inclusive), and the percentage progress of the entire calculation is taken to be the weighted sum of the progress of the individual stages. The weights of all stages should sum to 1.