From bf32085d63ccfa8fb1e0cff2f2ae7156b4679015 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 1 Sep 2024 01:37:10 +0200 Subject: 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 --- src/libstore/build/worker.cc | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'src/libstore/build/worker.cc') 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(); 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 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); } -- cgit v1.2.3