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:
parent
50dd7b47af
commit
dbc75000a5
@ -496,12 +496,36 @@ void Laminar::assignNewJobs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup run completion handler
|
// setup run completion handler
|
||||||
run->notifyCompletion = [=,&node](const Run* r) {
|
run->notifyCompletion = [this](const Run* r) { runFinished(r); };
|
||||||
node.busyExecutors--;
|
|
||||||
|
// 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));
|
KJ_LOG(INFO, "Run completed", r->name, to_string(r->result));
|
||||||
time_t completedAt = time(0);
|
time_t completedAt = time(0);
|
||||||
db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?)")
|
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())
|
r->log, r->parentName, r->parentBuild, r->reason())
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
@ -527,28 +551,8 @@ void Laminar::assignNewJobs() {
|
|||||||
waiters.erase(r);
|
waiters.erase(r);
|
||||||
|
|
||||||
// remove the workdir
|
// remove the workdir
|
||||||
fs::remove_all(wd);
|
fs::remove_all(r->wd);
|
||||||
|
|
||||||
// will delete the job
|
// will delete the job
|
||||||
activeJobs.get<2>().erase(r);
|
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
void reapAdvance();
|
void reapAdvance();
|
||||||
void assignNewJobs();
|
void assignNewJobs();
|
||||||
bool stepRun(std::shared_ptr<Run> run);
|
bool stepRun(std::shared_ptr<Run> run);
|
||||||
|
void runFinished(const Run*);
|
||||||
|
|
||||||
std::list<std::shared_ptr<Run>> queuedJobs;
|
std::list<std::shared_ptr<Run>> queuedJobs;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user