Skip to content
Snippets Groups Projects
Commit 01a8b038 authored by Nicolas Voirol's avatar Nicolas Voirol
Browse files

Solver package (implicit timeoutSolver wrapper)

parent 0b108395
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
package inox
package solvers
package combinators
import utils._
import scala.concurrent.duration._
......
......@@ -2,6 +2,7 @@
package inox
package solvers
package combinators
import scala.reflect.runtime.universe._
......
/* Copyright 2009-2016 EPFL, Lausanne */
package leon
package inox
import scala.reflect.runtime.universe._
import scala.concurrent.duration._
package object solvers {
implicit class TimeoutableSolverFactory[+S <: TimeoutSolver : TypeTag](val sf: SolverFactory[S]) {
def withTimeout(to: Long): TimeoutSolverFactory[S] = {
sf match {
case tsf: TimeoutSolverFactory[_] =>
new TimeoutSolverFactory[S](tsf.sf, to)
case _ =>
new TimeoutSolverFactory[S](sf, to)
import combinators._
implicit class TimeoutableSolverFactory[S1 <: TimeoutSolver](val sf: SolverFactory { type S = S1 }) {
def withTimeout(timeout: Long): TimeoutSolverFactory { type S <: S1 } = {
val innerFactory = (sf match {
case tsf: TimeoutSolverFactory => tsf.factory
case _ => sf
}).asInstanceOf[SolverFactory {
val program: sf.program.type
type S = S1 { val program: sf.program.type }
}]
new TimeoutSolverFactory {
val program: sf.program.type = sf.program
type S = S1 { val program: sf.program.type }
val to = timeout
val factory = innerFactory
}
}
def withTimeout(du: Duration): TimeoutSolverFactory[S] = {
def withTimeout(du: Duration): TimeoutSolverFactory { type S <: S1 } = {
withTimeout(du.toMillis)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment