Skip to content

Commit

Permalink
refactor Worker::childStarted/Terminated: use switch
Browse files Browse the repository at this point in the history
Preparation for RFC 92 dynamic derivations.
  • Loading branch information
roberth committed Nov 20, 2023
1 parent 7ac39ff commit ffae6ff
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/libstore/build/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,16 @@ void Worker::childStarted(GoalPtr goal, const std::set<int> & fds,
child.respectTimeouts = respectTimeouts;
children.emplace_back(child);
if (inBuildSlot) {
if (goal->jobCategory() == JobCategory::Substitution) nrSubstitutions++;
else nrLocalBuilds++;
switch (goal->jobCategory()) {
case JobCategory::Substitution:
nrSubstitutions++;
break;
case JobCategory::Build:
nrLocalBuilds++;
break;
default:
abort();
}
}
}

Expand All @@ -212,13 +220,17 @@ void Worker::childTerminated(Goal * goal, bool wakeSleepers)
if (i == children.end()) return;

if (i->inBuildSlot) {
if (goal->jobCategory() == JobCategory::Substitution) {
switch (goal->jobCategory()) {
case JobCategory::Substitution:
assert(nrSubstitutions > 0);
nrSubstitutions--;
} else {
break;
case JobCategory::Build:
assert(nrLocalBuilds > 0);
nrLocalBuilds--;
}
break;
default:
abort();
}

children.erase(i);
Expand Down

0 comments on commit ffae6ff

Please sign in to comment.