Linkgraph: Allow job threads to be aborted early when clearing schedule.

This commit is contained in:
Jonathan G Rennison
2016-11-26 00:33:50 +00:00
parent d08d1cbd67
commit 375dbdbfe1
3 changed files with 43 additions and 2 deletions

View File

@@ -130,6 +130,7 @@ void LinkGraphSchedule::JoinNext()
this->running.pop_front();
LinkGraphID id = next->LinkGraphIndex();
next->FinaliseJob(); // joins the thread and finalises the job
assert(!next->IsJobAborted());
next.reset();
if (LinkGraph::IsValidID(id)) {
LinkGraph *lg = LinkGraph::Get(id);
@@ -148,6 +149,7 @@ void LinkGraphSchedule::JoinNext()
{
LinkGraphJob *job = (LinkGraphJob *)j;
for (uint i = 0; i < lengthof(instance.handlers); ++i) {
if (job->IsJobAborted()) return;
instance.handlers[i]->Run(*job);
}
@@ -186,7 +188,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();