Skip to content
Permalink
Browse files

Actually kill jobs on reduction of j

  • Loading branch information...
Andersbakken committed Sep 10, 2019
1 parent 52ad612 commit 7dfdf51d004a73cb376e6d0d2a984c3c77dee745
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/JobScheduler.cpp
@@ -114,6 +114,21 @@ void JobScheduler::startJobs()
<< "slots" << slots << "daemonCount" << options.daemonCount << "active daemons" << mActiveDaemonsByProcess.size() << "\n"
<< "daemonSlots" << daemonSlots;

if (options.jobCount < mActiveByProcess.size()) {
List<std::shared_ptr<Node> > nodes;
nodes.reserve(mActiveByProcess.size());
for (const auto &pair : mActiveByProcess) {
nodes.push_back(pair.second);
}
std::sort(nodes.begin(), nodes.end(), [](const std::shared_ptr<Node> &l, const std::shared_ptr<Node> &r) -> bool {
return l->started > r->started;
});
const size_t c = mActiveByProcess.size() - options.jobCount;
for (size_t i=0; i<c; ++i) {
debug() << "Killing process" << nodes[i]->started;
nodes[i]->process->kill();
}
}
std::shared_ptr<Node> node = mPendingJobs.first();
while (node && (slots || daemonSlots)) {
const Server::ActiveBufferType type = Server::instance()->activeBufferType(node->job->sourceFileId());

0 comments on commit 7dfdf51

Please sign in to comment.
You can’t perform that action at this time.