about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-14T20·42+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-16T18·56+0200
commitbf1f123b09ec7402b0565808619e11b5bfe6b16b (patch)
treed0e4c9af039b8bf05244f648907c21274ee37054 /src/libstore/build.cc
parent0e0dcf2c7ec054f1b30629e275f53f56039b8257 (diff)
Progress indicator: Show number of active items
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 9ea4e4b88ef9..a45ca8923016 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -202,16 +202,6 @@ struct Child
 };
 
 
-template<typename T>
-struct MaintainCount
-{
-    T & counter;
-    T delta;
-    MaintainCount(T & counter, T delta = 1) : counter(counter), delta(delta) { counter += delta; }
-    ~MaintainCount() { counter -= delta; }
-};
-
-
 /* The worker class. */
 class Worker
 {
@@ -271,6 +261,7 @@ public:
 
     uint64_t expectedSubstitutions = 0;
     uint64_t doneSubstitutions = 0;
+    uint64_t runningSubstitutions = 0;
     uint64_t expectedDownloadSize = 0;
     uint64_t doneDownloadSize = 0;
     uint64_t expectedNarSize = 0;
@@ -337,7 +328,7 @@ public:
 
     void updateProgress()
     {
-        actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions);
+        actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions, runningSubstitutions);
         logger->event(evSetExpected, act, actDownload, expectedDownloadSize + doneDownloadSize);
         logger->event(evSetExpected, act, actCopyPath, expectedNarSize + doneNarSize);
     }
@@ -3333,7 +3324,7 @@ private:
     Path destPath;
 
     std::unique_ptr<MaintainCount<uint64_t>> maintainExpectedSubstitutions,
-        maintainExpectedNar, maintainExpectedDownload;
+        maintainRunningSubstitutions, maintainExpectedNar, maintainExpectedDownload;
 
     typedef void (SubstitutionGoal::*GoalState)();
     GoalState state;
@@ -3531,6 +3522,9 @@ void SubstitutionGoal::tryToRun()
 
     printInfo(format("fetching path '%1%'...") % storePath);
 
+    maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions);
+    worker.updateProgress();
+
     outPipe.create();
 
     promise = std::promise<void>();
@@ -3578,6 +3572,8 @@ void SubstitutionGoal::finished()
     printMsg(lvlChatty,
         format("substitution of path '%1%' succeeded") % storePath);
 
+    maintainRunningSubstitutions.reset();
+
     maintainExpectedSubstitutions.reset();
     worker.doneSubstitutions++;