mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-12 17:58:55 +08:00
Updated ProgressBar API to check if completed. Updated tick() method
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
||||
std::unique_lock<std::mutex> lock{_mutex};
|
||||
if (_completed) return;
|
||||
_progress = value;
|
||||
if (static_cast<int>(_progress) == 100) {
|
||||
if (_progress >= 100.0) {
|
||||
_completed = true;
|
||||
}
|
||||
}
|
||||
@@ -78,8 +78,19 @@ public:
|
||||
}
|
||||
|
||||
void tick() {
|
||||
if (_completed) return;
|
||||
set_progress(_progress + 1);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock{_mutex};
|
||||
if (_completed) return;
|
||||
_progress += 1;
|
||||
if (_progress >= 100.0) {
|
||||
_completed = true;
|
||||
}
|
||||
}
|
||||
_print_progress();
|
||||
}
|
||||
|
||||
bool completed() {
|
||||
return _completed;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user