aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-09-01 01:37:10 +0200
committereldritch horrors <pennae@lix.systems>2024-09-27 16:40:26 +0200
commitbf32085d63ccfa8fb1e0cff2f2ae7156b4679015 (patch)
treef0bf82ed7863f73e55362ef2661d36e1f697dca8 /src/libstore/build/worker.cc
parentcd1ceffb0ee9544bf14453f94da6b6f0d52f10cd (diff)
libstore: simplify Worker::waitForInput
with waitForAWhile turned into promised the core functionality of waitForInput is now merely to let gc run every so often if needed Change-Id: I68da342bbc1d67653901cf4502dabfa5bc947628
Diffstat (limited to 'src/libstore/build/worker.cc')
-rw-r--r--src/libstore/build/worker.cc27
1 files changed, 3 insertions, 24 deletions
diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc
index 27d8e6ee1..2cc2828b1 100644
--- a/src/libstore/build/worker.cc
+++ b/src/libstore/build/worker.cc
@@ -438,38 +438,17 @@ void Worker::waitForInput()
{
printMsg(lvlVomit, "waiting for children");
- auto childFinished = [&]{
+ auto waitFor = [&]{
auto pair = kj::newPromiseAndFulfiller<void>();
this->childFinished = kj::mv(pair.fulfiller);
return kj::mv(pair.promise);
}();
- /* Process output from the file descriptors attached to the
- children, namely log output and output path creation commands.
- We also use this to detect child termination: if we get EOF on
- the logger pipe of a build, we assume that the builder has
- terminated. */
-
- std::optional<long> timeout = 0;
-
- // Periodicallty wake up to see if we need to run the garbage collector.
if (settings.minFree.get() != 0) {
- timeout = 10;
+ // Periodicallty wake up to see if we need to run the garbage collector.
+ waitFor = waitFor.exclusiveJoin(aio.provider->getTimer().afterDelay(10 * kj::SECONDS));
}
- if (timeout)
- vomit("sleeping %d seconds", *timeout);
-
- auto waitFor = [&] {
- if (timeout) {
- return aio.provider->getTimer()
- .afterDelay(*timeout * kj::SECONDS)
- .exclusiveJoin(kj::mv(childFinished));
- } else {
- return std::move(childFinished);
- }
- }();
-
waitFor.wait(aio.waitScope);
}