libstore: remove Worker::{childStarted, goalFinished}

these two functions are now nearly trivial and much better inline into
makeGoalCommon. keeping them separate also separates information about
goal completion flows and how failure information ends up in `Worker`.

Change-Id: I6af86996e4a2346583371186595e3013c88fb082
This commit is contained in:
eldritch horrors 2024-10-05 00:38:35 +02:00
parent 649d8cd08f
commit ed9b7f4f84
2 changed files with 9 additions and 28 deletions

View file

@ -94,7 +94,15 @@ std::pair<std::shared_ptr<G>, kj::Promise<Result<Goal::WorkResult>>> Worker::mak
}(goal, map, it); }(goal, map, it);
}; };
cachedGoal.promise = kj::evalLater(std::move(removeWhenDone)).fork(); cachedGoal.promise = kj::evalLater(std::move(removeWhenDone)).fork();
childStarted(goal, cachedGoal.promise.addBranch()); children.add(cachedGoal.promise.addBranch().then([this](auto _result) {
if (_result.has_value()) {
auto & result = _result.value();
permanentFailure |= result.permanentFailure;
timedOut |= result.timedOut;
hashMismatch |= result.hashMismatch;
checkMismatch |= result.checkMismatch;
}
}));
} else { } else {
if (!modify(*goal)) { if (!modify(*goal)) {
cachedGoal = {}; cachedGoal = {};
@ -195,26 +203,6 @@ std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>> Worker::makeGoal(const
}, req.raw()); }, req.raw());
} }
void Worker::goalFinished(GoalPtr goal, Goal::WorkResult & f)
{
permanentFailure |= f.permanentFailure;
timedOut |= f.timedOut;
hashMismatch |= f.hashMismatch;
checkMismatch |= f.checkMismatch;
}
void Worker::childStarted(GoalPtr goal, kj::Promise<Result<Goal::WorkResult>> promise)
{
children.add(promise
.then([this, goal](auto result) {
if (result.has_value()) {
goalFinished(goal, result.assume_value());
}
}));
}
kj::Promise<Result<Worker::Results>> Worker::updateStatistics() kj::Promise<Result<Worker::Results>> Worker::updateStatistics()
try { try {
while (true) { while (true) {

View file

@ -132,13 +132,6 @@ private:
*/ */
bool checkMismatch = false; bool checkMismatch = false;
void goalFinished(GoalPtr goal, Goal::WorkResult & f);
/**
* Registers a running child process.
*/
void childStarted(GoalPtr goal, kj::Promise<Result<Goal::WorkResult>> promise);
/** /**
* Pass current stats counters to the logger for progress bar updates. * Pass current stats counters to the logger for progress bar updates.
*/ */