diff --git a/src/linkgraph/linkgraphjob.h b/src/linkgraph/linkgraphjob.h index 122447867b..146ddc7117 100644 --- a/src/linkgraph/linkgraphjob.h +++ b/src/linkgraph/linkgraphjob.h @@ -74,10 +74,11 @@ protected: void EraseFlows(NodeID from); void JoinThread(); void SetJobGroup(std::shared_ptr group); - bool IsJobAborted() const; public: + bool IsJobAborted() const; + /** * A job edge. Wraps a link graph edge and an edge annotation. The * annotation can be modified, the edge is constant. diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index 2972f4aaf9..547f6ed5f0 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -638,7 +638,7 @@ MCF1stPass::MCF1stPass(LinkGraphJob &job) : MultiCommodityFlow(job) } this->CleanupPaths(source, paths); } - } while (more_loops || this->EliminateCycles()); + } while ((more_loops || this->EliminateCycles()) && !job.IsJobAborted()); } /** @@ -653,7 +653,7 @@ MCF2ndPass::MCF2ndPass(LinkGraphJob &job) : MultiCommodityFlow(job) uint size = job.Size(); uint accuracy = job.Settings().accuracy; bool demand_left = true; - while (demand_left) { + while (demand_left && !job.IsJobAborted()) { demand_left = false; for (NodeID source = 0; source < size; ++source) { this->Dijkstra(source, paths);