Change: [Linkgraph] Allow job threads to be aborted early when clearing schedule (#8416)

When link graph jobs are cleared due to abandoning the game or exiting,
flag the job as aborted.
The link graph job running in a separate thread checks the aborted flag
periodically and terminates processing early if set.
This reduces the delay at game abandon or exit if a long-running job
would otherwise still be running.
This commit is contained in:
Jonathan G Rennison
2020-12-24 23:36:36 +00:00
committed by GitHub
parent ad47e3d9e6
commit 94d629d79b
4 changed files with 28 additions and 5 deletions

View File

@@ -528,7 +528,7 @@ MCF1stPass::MCF1stPass(LinkGraphJob &job) : MultiCommodityFlow(job)
finished_sources[source] = !source_demand_left;
this->CleanupPaths(source, paths);
}
} while (more_loops || this->EliminateCycles());
} while ((more_loops || this->EliminateCycles()) && !job.IsJobAborted());
}
/**
@@ -544,7 +544,7 @@ MCF2ndPass::MCF2ndPass(LinkGraphJob &job) : MultiCommodityFlow(job)
uint accuracy = job.Settings().accuracy;
bool demand_left = true;
std::vector<bool> finished_sources(size);
while (demand_left) {
while (demand_left && !job.IsJobAborted()) {
demand_left = false;
for (NodeID source = 0; source < size; ++source) {
if (finished_sources[source]) continue;