diff --git a/lix/libstore/build/entry-points.cc b/lix/libstore/build/entry-points.cc index fc29aae39..db4c3f891 100644 --- a/lix/libstore/build/entry-points.cc +++ b/lix/libstore/build/entry-points.cc @@ -2,21 +2,19 @@ #include "lix/libstore/build/substitution-goal.hh" #include "lix/libstore/build/derivation-goal.hh" #include "lix/libstore/local-store.hh" +#include "lix/libutil/async.hh" #include "lix/libutil/strings.hh" namespace nix { void Store::buildPaths(const std::vector & reqs, BuildMode buildMode, std::shared_ptr evalStore) { - auto kjaio = kj::setupAsyncIo(); - AsyncContext aio(kjaio); - - auto results = processGoals(*this, evalStore ? *evalStore : *this, [&](GoalFactory & gf) { + auto results = RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, evalStore ? *evalStore : *this, [&](GoalFactory & gf) { Worker::Targets goals; for (auto & br : reqs) goals.emplace_back(gf.makeGoal(br, buildMode)); return goals; - }).wait(kjaio.waitScope).value(); + })); StringSet failed; std::shared_ptr ex; @@ -47,16 +45,13 @@ std::vector Store::buildPathsWithResults( BuildMode buildMode, std::shared_ptr evalStore) { - auto kjaio = kj::setupAsyncIo(); - AsyncContext aio(kjaio); - - auto goals = processGoals(*this, evalStore ? *evalStore : *this, [&](GoalFactory & gf) { + auto goals = RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, evalStore ? *evalStore : *this, [&](GoalFactory & gf) { Worker::Targets goals; for (const auto & req : reqs) { goals.emplace_back(gf.makeGoal(req, buildMode)); } return goals; - }).wait(kjaio.waitScope).value().goals; + })).goals; std::vector results; @@ -69,15 +64,12 @@ std::vector Store::buildPathsWithResults( BuildResult Store::buildDerivation(const StorePath & drvPath, const BasicDerivation & drv, BuildMode buildMode) { - auto kjaio = kj::setupAsyncIo(); - AsyncContext aio(kjaio); - try { - auto results = processGoals(*this, *this, [&](GoalFactory & gf) { + auto results = RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, *this, [&](GoalFactory & gf) { Worker::Targets goals; goals.emplace_back(gf.makeBasicDerivationGoal(drvPath, drv, OutputsSpec::All{}, buildMode)); return goals; - }).wait(kjaio.waitScope).value(); + })); auto & result = results.goals.begin()->second; return result.result.restrictTo(DerivedPath::Built { .drvPath = makeConstantStorePathRef(drvPath), @@ -97,14 +89,11 @@ void Store::ensurePath(const StorePath & path) /* If the path is already valid, we're done. */ if (isValidPath(path)) return; - auto kjaio = kj::setupAsyncIo(); - AsyncContext aio(kjaio); - - auto results = processGoals(*this, *this, [&](GoalFactory & gf) { + auto results = RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, *this, [&](GoalFactory & gf) { Worker::Targets goals; goals.emplace_back(gf.makePathSubstitutionGoal(path)); return goals; - }).wait(kjaio.waitScope).value(); + })); auto & result = results.goals.begin()->second; if (result.exitCode != Goal::ecSuccess) { @@ -119,14 +108,11 @@ void Store::ensurePath(const StorePath & path) void Store::repairPath(const StorePath & path) { - auto kjaio = kj::setupAsyncIo(); - AsyncContext aio(kjaio); - - auto results = processGoals(*this, *this, [&](GoalFactory & gf) { + auto results = RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, *this, [&](GoalFactory & gf) { Worker::Targets goals; goals.emplace_back(gf.makePathSubstitutionGoal(path, Repair)); return goals; - }).wait(kjaio.waitScope).value(); + })); auto & result = results.goals.begin()->second; if (result.exitCode != Goal::ecSuccess) { @@ -134,7 +120,7 @@ void Store::repairPath(const StorePath & path) deriver, then rebuild the deriver. */ auto info = queryPathInfo(path); if (info->deriver && isValidPath(*info->deriver)) { - processGoals(*this, *this, [&](GoalFactory & gf) { + RUN_ASYNC_IN_NEW_THREAD(processGoals(*this, *this, [&](GoalFactory & gf) { Worker::Targets goals; goals.emplace_back(gf.makeGoal( DerivedPath::Built{ @@ -145,7 +131,7 @@ void Store::repairPath(const StorePath & path) bmRepair )); return goals; - }).wait(kjaio.waitScope).value(); + })); } else throw Error(results.failingExitStatus, "cannot repair path '%s'", printStorePath(path)); }