1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

readability: move runFinished into its own function

This commit is contained in:
Oliver Giles 2015-09-19 15:41:19 +02:00
parent 50dd7b47af
commit dbc75000a5
2 changed files with 41 additions and 36 deletions

View File

@ -496,12 +496,36 @@ void Laminar::assignNewJobs() {
}
// setup run completion handler
run->notifyCompletion = [=,&node](const Run* r) {
node.busyExecutors--;
run->notifyCompletion = [this](const Run* r) { runFinished(r); };
// trigger the first step of the run
if(stepRun(run)) {
// should never happen
KJ_LOG(INFO, "No steps for run");
run->complete();
}
assigned = true;
break;
}
}
if(assigned) {
activeJobs.insert(*it);
it = queuedJobs.erase(it);
} else
++it;
}
}
void Laminar::runFinished(const Run * r) {
Node* node = r->node;
node->busyExecutors--;
KJ_LOG(INFO, "Run completed", r->name, to_string(r->result));
time_t completedAt = time(0);
db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?)")
.bind(r->name, r->build, node.name, r->queuedAt, r->startedAt, completedAt, int(r->result),
.bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result),
r->log, r->parentName, r->parentBuild, r->reason())
.exec();
@ -527,28 +551,8 @@ void Laminar::assignNewJobs() {
waiters.erase(r);
// remove the workdir
fs::remove_all(wd);
fs::remove_all(r->wd);
// will delete the job
activeJobs.get<2>().erase(r);
};
// trigger the first step of the run
if(stepRun(run)) {
// should never happen
KJ_LOG(INFO, "No steps for run");
run->complete();
}
assigned = true;
break;
}
}
if(assigned) {
activeJobs.insert(*it);
it = queuedJobs.erase(it);
} else
++it;
}
}

View File

@ -59,6 +59,7 @@ private:
void reapAdvance();
void assignNewJobs();
bool stepRun(std::shared_ptr<Run> run);
void runFinished(const Run*);
std::list<std::shared_ptr<Run>> queuedJobs;