diff --git a/src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5AbstractProver.java b/src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5AbstractProver.java index 5facef977b..c7846bc74a 100644 --- a/src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5AbstractProver.java +++ b/src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5AbstractProver.java @@ -30,7 +30,6 @@ import com.google.common.base.Preconditions; import com.google.common.base.Splitter; -import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.primitives.Longs; @@ -42,7 +41,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.concurrent.Callable; import org.sosy_lab.common.ShutdownNotifier; import org.sosy_lab.java_smt.api.BooleanFormula; import org.sosy_lab.java_smt.api.Evaluator; @@ -97,24 +95,18 @@ private long buildConfig(Set opts) { /** add needed options into the given map. */ protected abstract void createConfig(Map pConfig); - private T exec(Callable closure) throws SolverException, InterruptedException { + @Override + public boolean isUnsat() throws InterruptedException, SolverException { + Preconditions.checkState(!closed); + long hook = context.addTerminationTest(curEnv); - T value = null; + boolean result; try { - value = closure.call(); - } catch (Throwable t) { - Throwables.propagateIfPossible(t, IllegalStateException.class, SolverException.class); - Throwables.propagateIfPossible(t, InterruptedException.class); + result = !msat_check_sat(curEnv); } finally { msat_free_termination_callback(hook); } - return value; - } - - @Override - public boolean isUnsat() throws InterruptedException, SolverException { - Preconditions.checkState(!closed); - return exec(() -> !msat_check_sat(curEnv)); + return result; } @Override @@ -122,7 +114,15 @@ public boolean isUnsatWithAssumptions(Collection pAssumptions) throws SolverException, InterruptedException { Preconditions.checkState(!closed); checkForLiterals(pAssumptions); - return exec(() -> !msat_check_sat_with_assumptions(curEnv, getMsatTerm(pAssumptions))); + + long hook = context.addTerminationTest(curEnv); + boolean result; + try { + result = !msat_check_sat_with_assumptions(curEnv, getMsatTerm(pAssumptions)); + } finally { + msat_free_termination_callback(hook); + } + return result; } private void checkForLiterals(Collection formulas) {