Skip to content
Snippets Groups Projects
Commit 45985e1b authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

More reliable shutdown

parent c5e13beb
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,11 @@ class ParallelSearch(synth: Synthesizer, ...@@ -23,6 +23,11 @@ class ParallelSearch(synth: Synthesizer,
SynthesisContext(solver = solver, reporter = synth.reporter, shouldStop = synth.shouldStop) SynthesisContext(solver = solver, reporter = synth.reporter, shouldStop = synth.shouldStop)
} }
override def stop() = {
synth.shouldStop.set(true)
super.stop()
}
def expandAndTask(ref: ActorRef, sctx: SynthesisContext)(t: TaskRunRule) = { def expandAndTask(ref: ActorRef, sctx: SynthesisContext)(t: TaskRunRule) = {
val prefix = "[%-20s] ".format(Option(t.rule).getOrElse("?")) val prefix = "[%-20s] ".format(Option(t.rule).getOrElse("?"))
......
...@@ -69,7 +69,7 @@ class SimpleSearch(synth: Synthesizer, ...@@ -69,7 +69,7 @@ class SimpleSearch(synth: Synthesizer,
} }
def search(): Option[Solution] = { def search(): Option[Solution] = {
while (!g.tree.isSolved && !isStopped) { while (!g.tree.isSolved) {
nextLeaf() match { nextLeaf() match {
case Some(l) => case Some(l) =>
l match { l match {
......
...@@ -14,7 +14,7 @@ abstract class AndOrGraphParallelSearch[WC, ...@@ -14,7 +14,7 @@ abstract class AndOrGraphParallelSearch[WC,
def initWorkerContext(w: ActorRef): WC def initWorkerContext(w: ActorRef): WC
val nWorkers = 5 val nWorkers = 7
val timeout = 600.seconds val timeout = 600.seconds
var system: ActorSystem = _ var system: ActorSystem = _
...@@ -128,8 +128,10 @@ abstract class AndOrGraphParallelSearch[WC, ...@@ -128,8 +128,10 @@ abstract class AndOrGraphParallelSearch[WC,
sendWork() sendWork()
case Terminated(w) => case Terminated(w) =>
processing -= workers(w).get if (workers contains w) {
workers -= w processing -= workers(w).get
workers -= w
}
} }
} }
......
...@@ -60,10 +60,8 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S], ...@@ -60,10 +60,8 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S],
case class ExpandSuccess[T <: AOTask[S]](sol: S) extends ExpandResult[T] case class ExpandSuccess[T <: AOTask[S]](sol: S) extends ExpandResult[T]
case class ExpandFailure[T <: AOTask[S]]() extends ExpandResult[T] case class ExpandFailure[T <: AOTask[S]]() extends ExpandResult[T]
var isStopped = false
def stop() { def stop() {
isStopped = true
} }
def search(): Option[S] def search(): Option[S]
...@@ -79,6 +77,11 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S], ...@@ -79,6 +77,11 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S],
al.isUnsolvable = true al.isUnsolvable = true
al.parent.unsolvable(al) al.parent.unsolvable(al)
} }
if (g.tree.isSolved) {
stop()
}
processing -= al processing -= al
} }
...@@ -93,6 +96,11 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S], ...@@ -93,6 +96,11 @@ abstract class AndOrGraphSearch[AT <: AOAndTask[S],
ol.isUnsolvable = true ol.isUnsolvable = true
ol.parent.unsolvable(ol) ol.parent.unsolvable(ol)
} }
if (g.tree.isSolved) {
stop()
}
processing -= ol processing -= ol
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment