mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Added multi-threaded progress bar example
This commit is contained in:
22
test/bar.cpp
22
test/bar.cpp
@@ -18,10 +18,24 @@ int main() {
|
||||
//
|
||||
//
|
||||
|
||||
for (size_t i = 0; i < 101; i += 5) {
|
||||
bar.set_progress(i);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
std::thread first_job(
|
||||
[&bar]() {
|
||||
for (size_t i = 0; i <= 50; ++i) {
|
||||
bar.tick();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
});
|
||||
|
||||
std::thread second_job(
|
||||
[&bar]() {
|
||||
for (size_t i = 0; i <= 50; ++i) {
|
||||
bar.tick();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
});
|
||||
|
||||
first_job.join();
|
||||
second_job.join();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user