about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-06-19T07·13+0200
committerGitHub <noreply@github.com>2018-06-19T07·13+0200
commit629398d05cc7ed42d0b676b2f02ee8985d2668be (patch)
treec1f26f9d23a599eb2e8734593de88b2e54249e16
parent1fb475e7fce5050ae70cab3bb918ae2217f69123 (diff)
parent44de71a39624d86d6744062ee36f57170024c9a0 (diff)
Merge pull request #2241 from dtzWill/feature/refresh-progress-bar
progress-bar: refresh occasionally even if no updates are received
-rw-r--r--src/libutil/sync.hh4
-rw-r--r--src/nix/progress-bar.cc5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/libutil/sync.hh b/src/libutil/sync.hh
index 3b2710f6fd30..e1d591d77a84 100644
--- a/src/libutil/sync.hh
+++ b/src/libutil/sync.hh
@@ -57,11 +57,11 @@ public:
         }
 
         template<class Rep, class Period>
-        void wait_for(std::condition_variable & cv,
+        std::cv_status wait_for(std::condition_variable & cv,
             const std::chrono::duration<Rep, Period> & duration)
         {
             assert(s);
-            cv.wait_for(lk, duration);
+            return cv.wait_for(lk, duration);
         }
 
         template<class Rep, class Period, class Predicate>
diff --git a/src/nix/progress-bar.cc b/src/nix/progress-bar.cc
index 40b905ba3243..8093d8761c4d 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));
             }
         });
     }