2019-12-17 20:21:33 -06:00
|
|
|
#include <indicators/block_progress_bar.hpp>
|
2019-12-17 20:06:50 -06:00
|
|
|
#include <indicators/multi_progress.hpp>
|
|
|
|
|
|
|
|
|
|
int main() {
|
2020-02-10 21:48:36 +01:00
|
|
|
using namespace indicators;
|
2020-02-13 14:21:01 +05:30
|
|
|
BlockProgressBar bar1{option::BarWidth{50}, option::ForegroundColor{Color::yellow},
|
|
|
|
|
option::ShowElapsedTime{true}, option::ShowRemainingTime{true},
|
|
|
|
|
option::PrefixText{"Progress Bar #1 "}};
|
2019-12-17 20:06:50 -06:00
|
|
|
|
2020-02-13 14:21:01 +05:30
|
|
|
BlockProgressBar bar2{option::BarWidth{50}, option::ForegroundColor{Color::cyan},
|
|
|
|
|
option::ShowElapsedTime{true}, option::ShowRemainingTime{true},
|
|
|
|
|
option::PrefixText{"Progress Bar #2 "}};
|
2019-12-17 20:06:50 -06:00
|
|
|
|
2020-02-13 14:21:01 +05:30
|
|
|
BlockProgressBar bar3{option::BarWidth{50}, option::ForegroundColor{Color::red},
|
|
|
|
|
option::ShowElapsedTime{true}, option::ShowRemainingTime{true},
|
|
|
|
|
option::PrefixText{"Progress Bar #3 "}};
|
2019-12-17 20:06:50 -06:00
|
|
|
|
2019-12-18 11:51:58 -06:00
|
|
|
indicators::MultiProgress<indicators::BlockProgressBar, 3> bars(bar1, bar2, bar3);
|
2019-12-17 20:06:50 -06:00
|
|
|
|
|
|
|
|
std::cout << "Multiple Progress Bars:\n";
|
|
|
|
|
|
|
|
|
|
auto job1 = [&bars]() {
|
|
|
|
|
while (true) {
|
|
|
|
|
bars.tick<0>();
|
|
|
|
|
if (bars.is_completed<0>())
|
|
|
|
|
break;
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto job2 = [&bars]() {
|
|
|
|
|
while (true) {
|
|
|
|
|
bars.tick<1>();
|
|
|
|
|
if (bars.is_completed<1>())
|
|
|
|
|
break;
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto job3 = [&bars]() {
|
|
|
|
|
while (true) {
|
|
|
|
|
bars.tick<2>();
|
|
|
|
|
if (bars.is_completed<2>())
|
|
|
|
|
break;
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(60));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::thread first_job(job1);
|
|
|
|
|
std::thread second_job(job2);
|
|
|
|
|
std::thread third_job(job3);
|
|
|
|
|
|
|
|
|
|
first_job.join();
|
|
|
|
|
second_job.join();
|
|
|
|
|
third_job.join();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|