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