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:

committed by
GitHub

parent
ad47e3d9e6
commit
94d629d79b
@@ -38,7 +38,8 @@ LinkGraphJob::LinkGraphJob(const LinkGraph &orig) :
|
||||
link_graph(orig),
|
||||
settings(_settings_game.linkgraph),
|
||||
join_date(_date + _settings_game.linkgraph.recalc_time),
|
||||
job_completed(false)
|
||||
job_completed(false),
|
||||
job_aborted(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -92,6 +93,11 @@ LinkGraphJob::~LinkGraphJob()
|
||||
* Accessing other pools may be invalid. */
|
||||
if (CleaningPool()) return;
|
||||
|
||||
/* If the job has been aborted, the job state is invalid.
|
||||
* This should never be reached, as once the job has been marked as aborted
|
||||
* the only valid job operation is to clear the LinkGraphJob pool. */
|
||||
assert(!this->IsJobAborted());
|
||||
|
||||
/* Link graph has been merged into another one. */
|
||||
if (!LinkGraph::IsValidID(this->link_graph.index)) return;
|
||||
|
||||
|
Reference in New Issue
Block a user