libstore: make Worker::waitForBuildSlot private
Change-Id: I02a54846cd65622edbd7a1d6c24a623b4a59e5b3
This commit is contained in:
parent
6fdb47f0b2
commit
b33c969519
6 changed files with 12 additions and 13 deletions
|
@ -41,8 +41,7 @@ Goal::WorkResult DrvOutputSubstitutionGoal::tryNext()
|
||||||
if maxSubstitutionJobs == 0, we still allow a substituter to run. This
|
if maxSubstitutionJobs == 0, we still allow a substituter to run. This
|
||||||
prevents infinite waiting. */
|
prevents infinite waiting. */
|
||||||
if (worker.runningSubstitutions >= std::max(1U, settings.maxSubstitutionJobs.get())) {
|
if (worker.runningSubstitutions >= std::max(1U, settings.maxSubstitutionJobs.get())) {
|
||||||
worker.waitForBuildSlot(shared_from_this());
|
return WaitForSlot{};
|
||||||
return StillAlive{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maintainRunningSubstitutions =
|
maintainRunningSubstitutions =
|
||||||
|
|
|
@ -106,12 +106,13 @@ struct Goal : public std::enable_shared_from_this<Goal>
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct [[nodiscard]] StillAlive {};
|
struct [[nodiscard]] StillAlive {};
|
||||||
|
struct [[nodiscard]] WaitForSlot {};
|
||||||
struct [[nodiscard]] Finished {
|
struct [[nodiscard]] Finished {
|
||||||
ExitCode result;
|
ExitCode result;
|
||||||
std::unique_ptr<Error> ex;
|
std::unique_ptr<Error> ex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct [[nodiscard]] WorkResult : std::variant<StillAlive, Finished>
|
struct [[nodiscard]] WorkResult : std::variant<StillAlive, WaitForSlot, Finished>
|
||||||
{
|
{
|
||||||
WorkResult() = delete;
|
WorkResult() = delete;
|
||||||
using variant::variant;
|
using variant::variant;
|
||||||
|
|
|
@ -158,9 +158,8 @@ Goal::WorkResult LocalDerivationGoal::tryLocalBuild()
|
||||||
unsigned int curBuilds = worker.getNrLocalBuilds();
|
unsigned int curBuilds = worker.getNrLocalBuilds();
|
||||||
if (curBuilds >= settings.maxBuildJobs) {
|
if (curBuilds >= settings.maxBuildJobs) {
|
||||||
state = &DerivationGoal::tryToBuild;
|
state = &DerivationGoal::tryToBuild;
|
||||||
worker.waitForBuildSlot(shared_from_this());
|
|
||||||
outputLocks.unlock();
|
outputLocks.unlock();
|
||||||
return StillAlive{};
|
return WaitForSlot{};
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(derivationType);
|
assert(derivationType);
|
||||||
|
|
|
@ -194,8 +194,7 @@ Goal::WorkResult PathSubstitutionGoal::tryToRun()
|
||||||
if maxSubstitutionJobs == 0, we still allow a substituter to run. This
|
if maxSubstitutionJobs == 0, we still allow a substituter to run. This
|
||||||
prevents infinite waiting. */
|
prevents infinite waiting. */
|
||||||
if (worker.getNrSubstitutions() >= std::max(1U, (unsigned int) settings.maxSubstitutionJobs)) {
|
if (worker.getNrSubstitutions() >= std::max(1U, (unsigned int) settings.maxSubstitutionJobs)) {
|
||||||
worker.waitForBuildSlot(shared_from_this());
|
return WaitForSlot{};
|
||||||
return StillAlive{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions);
|
maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions);
|
||||||
|
|
|
@ -187,6 +187,7 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
|
||||||
std::visit(
|
std::visit(
|
||||||
overloaded{
|
overloaded{
|
||||||
[&](Goal::StillAlive) {},
|
[&](Goal::StillAlive) {},
|
||||||
|
[&](Goal::WaitForSlot) { waitForBuildSlot(goal); },
|
||||||
[&](Goal::Finished & f) { goalFinished(goal, f); },
|
[&](Goal::Finished & f) { goalFinished(goal, f); },
|
||||||
},
|
},
|
||||||
how
|
how
|
||||||
|
|
|
@ -108,6 +108,12 @@ private:
|
||||||
void goalFinished(GoalPtr goal, Goal::Finished & f);
|
void goalFinished(GoalPtr goal, Goal::Finished & f);
|
||||||
void handleWorkResult(GoalPtr goal, Goal::WorkResult how);
|
void handleWorkResult(GoalPtr goal, Goal::WorkResult how);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put `goal` to sleep until a build slot becomes available (which
|
||||||
|
* might be right away).
|
||||||
|
*/
|
||||||
|
void waitForBuildSlot(GoalPtr goal);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const Activity act;
|
const Activity act;
|
||||||
|
@ -233,12 +239,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void childTerminated(Goal * goal);
|
void childTerminated(Goal * goal);
|
||||||
|
|
||||||
/**
|
|
||||||
* Put `goal` to sleep until a build slot becomes available (which
|
|
||||||
* might be right away).
|
|
||||||
*/
|
|
||||||
void waitForBuildSlot(GoalPtr goal);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for a few seconds and then retry this goal. Used when
|
* Wait for a few seconds and then retry this goal. Used when
|
||||||
* waiting for a lock held by another process. This kind of
|
* waiting for a lock held by another process. This kind of
|
||||||
|
|
Loading…
Reference in a new issue