summaryrefslogtreecommitdiff
path: root/src/linkgraph/linkgraphschedule.cpp
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2020-12-24 23:36:36 +0000
committerGitHub <noreply@github.com>2020-12-25 00:36:36 +0100
commit94d629d79bcd623a5c77daa3db742cd8fd43d7b4 (patch)
tree25691cf3b5a2babd913b350275e8753b6b053ce4 /src/linkgraph/linkgraphschedule.cpp
parentad47e3d9e6d07e5ee60a53ff53a8671058680da7 (diff)
downloadopenttd-94d629d79bcd623a5c77daa3db742cd8fd43d7b4.tar.xz
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.
Diffstat (limited to 'src/linkgraph/linkgraphschedule.cpp')
-rw-r--r--src/linkgraph/linkgraphschedule.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp
index 87ab4818a..ce28ec3d8 100644
--- a/src/linkgraph/linkgraphschedule.cpp
+++ b/src/linkgraph/linkgraphschedule.cpp
@@ -86,6 +86,7 @@ void LinkGraphSchedule::JoinNext()
/* static */ void LinkGraphSchedule::Run(LinkGraphJob *job)
{
for (uint i = 0; i < lengthof(instance.handlers); ++i) {
+ if (job->IsJobAborted()) return;
instance.handlers[i]->Run(*job);
}
@@ -119,7 +120,7 @@ void LinkGraphSchedule::SpawnAll()
/* static */ void LinkGraphSchedule::Clear()
{
for (JobList::iterator i(instance.running.begin()); i != instance.running.end(); ++i) {
- (*i)->JoinThread();
+ (*i)->AbortJob();
}
instance.running.clear();
instance.schedule.clear();