libstore: make Worker::wakeUp private

Change-Id: Iffa55272fe6ef4adaf3e9d4d25e5339792c2e460
This commit is contained in:
eldritch horrors 2024-08-02 17:00:57 +02:00
parent 3ecb46e3e7
commit 4c3010a1be
5 changed files with 14 additions and 15 deletions

View file

@ -648,8 +648,7 @@ Goal::WorkResult DerivationGoal::inputsRealised()
slot to become available, since we don't need one if there is a
build hook. */
state = &DerivationGoal::tryToBuild;
worker.wakeUp(shared_from_this());
return StillAlive{};
return ContinueImmediately{};
}
Goal::WorkResult DerivationGoal::started()
@ -763,8 +762,7 @@ Goal::WorkResult DerivationGoal::tryToBuild()
actLock.reset();
state = &DerivationGoal::tryLocalBuild;
worker.wakeUp(shared_from_this());
return StillAlive{};
return ContinueImmediately{};
}
Goal::WorkResult DerivationGoal::tryLocalBuild() {

View file

@ -108,12 +108,14 @@ public:
struct [[nodiscard]] StillAlive {};
struct [[nodiscard]] WaitForSlot {};
struct [[nodiscard]] WaitForAWhile {};
struct [[nodiscard]] ContinueImmediately {};
struct [[nodiscard]] Finished {
ExitCode result;
std::unique_ptr<Error> ex;
};
struct [[nodiscard]] WorkResult : std::variant<StillAlive, WaitForSlot, WaitForAWhile, Finished>
struct [[nodiscard]] WorkResult
: std::variant<StillAlive, WaitForSlot, WaitForAWhile, ContinueImmediately, Finished>
{
WorkResult() = delete;
using variant::variant;

View file

@ -181,8 +181,7 @@ Goal::WorkResult PathSubstitutionGoal::referencesValid()
assert(worker.store.isValidPath(i));
state = &PathSubstitutionGoal::tryToRun;
worker.wakeUp(shared_from_this());
return StillAlive{};
return ContinueImmediately{};
}
@ -255,8 +254,7 @@ Goal::WorkResult PathSubstitutionGoal::finished()
/* Try the next substitute. */
state = &PathSubstitutionGoal::tryNext;
worker.wakeUp(shared_from_this());
return StillAlive{};
return ContinueImmediately{};
}
worker.markContentsGood(storePath);

View file

@ -189,6 +189,7 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
[&](Goal::StillAlive) {},
[&](Goal::WaitForSlot) { waitForBuildSlot(goal); },
[&](Goal::WaitForAWhile) { waitForAWhile(goal); },
[&](Goal::ContinueImmediately) { wakeUp(goal); },
[&](Goal::Finished & f) { goalFinished(goal, f); },
},
how
@ -523,7 +524,7 @@ void Worker::waitForInput()
if (rd == 0 || (rd == -1 && errno == EIO)) {
debug("%1%: got EOF", goal->getName());
goal->handleEOF(k);
wakeUp(goal);
handleWorkResult(goal, Goal::ContinueImmediately{});
j->fds.erase(k);
} else if (rd == -1) {
if (errno != EINTR)

View file

@ -122,6 +122,11 @@ private:
*/
void waitForAWhile(GoalPtr goal);
/**
* Wake up a goal (i.e., there is something for it to do).
*/
void wakeUp(GoalPtr goal);
public:
const Activity act;
@ -219,11 +224,6 @@ public:
*/
void removeGoal(GoalPtr goal);
/**
* Wake up a goal (i.e., there is something for it to do).
*/
void wakeUp(GoalPtr goal);
/**
* Return the number of local build processes currently running (but not
* remote builds via the build hook).