diff --git a/core/src/main/scala/org/http4s/blaze/util/Execution.scala b/core/src/main/scala/org/http4s/blaze/util/Execution.scala index a7e89728c..02b1f4cf1 100644 --- a/core/src/main/scala/org/http4s/blaze/util/Execution.scala +++ b/core/src/main/scala/org/http4s/blaze/util/Execution.scala @@ -16,38 +16,19 @@ package org.http4s.blaze.util -import scala.concurrent.{ExecutionContext, Future, Promise} import java.util import org.log4s.getLogger import scala.annotation.tailrec -import scala.concurrent.duration.Duration -import scala.util.Try import scala.util.control.NonFatal +import scala.concurrent.ExecutionContext /** Special `ExecutionContext` instances. */ object Execution { private[this] val logger = getLogger - // Race a future vs a default value. The timer used is the default blaze scheduler - private[blaze] def withTimeout[T](d: Duration, fallback: Try[T])(f: Future[T]): Future[T] = - if (!d.isFinite) f - else if (f.isCompleted) f - else { - val p = Promise[T]() - val r = new Runnable { - def run(): Unit = - if (p.tryComplete(fallback)) - logger.debug(s"Future $f timed out after $d, yielding reesult $fallback") - } - // Race the future vs a timeout - Execution.scheduler.schedule(r, d) - f.onComplete(p.tryComplete(_))(Execution.directec) - p.future - } - /** A trampolining `ExecutionContext` * * This `ExecutionContext` is run thread locally to avoid context switches. Because this is a