From f601bc049258ed438aa6f8199c5be11770d44aaf Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 18 Jun 2018 17:31:00 -0500 Subject: sync.hh: return cv_status instead of dropping it, in case useful. --- src/libutil/sync.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libutil/sync.hh b/src/libutil/sync.hh index 3b2710f6f..e1d591d77 100644 --- a/src/libutil/sync.hh +++ b/src/libutil/sync.hh @@ -57,11 +57,11 @@ public: } template - void wait_for(std::condition_variable & cv, + std::cv_status wait_for(std::condition_variable & cv, const std::chrono::duration & duration) { assert(s); - cv.wait_for(lk, duration); + return cv.wait_for(lk, duration); } template -- cgit v1.2.3 From 44de71a39624d86d6744062ee36f57170024c9a0 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 18 Jun 2018 17:33:35 -0500 Subject: 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)); } }); } -- cgit v1.2.3