From 44de71a39624d86d6744062ee36f57170024c9a0 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 18 Jun 2018 17:33:35 -0500 Subject: [PATCH] progress-bar: re-draw last update if nothing new for 1sec. Slightly nicer behavior when updates are somewhat far apart (during a long linking step, perhaps) ensuring things don't appear unresponsive. If we wait the maximum amount for the update, don't bother waiting another 50ms (for rate-limiting purposes) and just check if we should quit. This also ensures we'll notice the request to quit within 1s if quit is signalled but there is not an udpate. (I'm not sure if this happens or not) --- src/nix/progress-bar.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nix/progress-bar.cc b/src/nix/progress-bar.cc index 40b905ba3..8093d8761 100644 --- a/src/nix/progress-bar.cc +++ b/src/nix/progress-bar.cc @@ -75,9 +75,10 @@ public: updateThread = std::thread([&]() { auto state(state_.lock()); while (state->active) { - state.wait(updateCV); + auto r = state.wait_for(updateCV, std::chrono::seconds(1)); draw(*state); - state.wait_for(quitCV, std::chrono::milliseconds(50)); + if (r == std::cv_status::no_timeout) + state.wait_for(quitCV, std::chrono::milliseconds(50)); } }); }