aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-09-30 01:31:30 +0200
committereldritch horrors <pennae@lix.systems>2024-10-01 11:55:29 +0000
commit9889c79fe355ce9d1b6ee7814cdeec0fbf70823a (patch)
tree5ca1679bf6b7062caafb64219fba70b348462617 /src/libstore/build/worker.hh
parent732de75f67f030886fd6bb421d49481caa3aa8cf (diff)
libstore: turn Worker::updateStatistics into a promise
we'll now loop to update displayed statistics, and use this loop to limit the update rate to 50 times per second. we could have updated much more frequently before this (once per iteration of `runImpl`), much faster than would ever be useful in practice. aggressive stats updates can even impede progress due to terminal or network delays. Change-Id: Ifba755a2569f73c919b1fbb06a142c0951395d6d
Diffstat (limited to 'src/libstore/build/worker.hh')
-rw-r--r--src/libstore/build/worker.hh7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh
index bb51a2114..d6cde8384 100644
--- a/src/libstore/build/worker.hh
+++ b/src/libstore/build/worker.hh
@@ -167,16 +167,17 @@ private:
/**
* Pass current stats counters to the logger for progress bar updates.
*/
- void updateStatistics();
+ kj::Promise<Result<void>> updateStatistics();
- bool statisticsOutdated = true;
+ AsyncSemaphore statisticsUpdateSignal{1};
+ std::optional<AsyncSemaphore::Token> statisticsUpdateInhibitor;
/**
* Mark statistics as outdated, such that `updateStatistics` will be called.
*/
void updateStatisticsLater()
{
- statisticsOutdated = true;
+ statisticsUpdateInhibitor = {};
}
kj::Promise<Result<void>> runImpl();