diff options
author | phaller <hallerp@gmail.com> | 2012-05-10 17:25:39 +0200 |
---|---|---|
committer | phaller <hallerp@gmail.com> | 2012-05-10 17:25:39 +0200 |
commit | 3fdc05278918df210b0c2b859f4588e14051bd41 (patch) | |
tree | 6b978fe63e99fb094ac47e4e91714b60a8ea7772 /src/library/scala/concurrent/impl | |
parent | b0e85333a286075882352f66e59e5aa3f287e62e (diff) | |
download | scala-3fdc05278918df210b0c2b859f4588e14051bd41.tar.gz scala-3fdc05278918df210b0c2b859f4588e14051bd41.tar.bz2 scala-3fdc05278918df210b0c2b859f4588e14051bd41.zip |
Move resolver and resolveEither to impl.Promise
Diffstat (limited to 'src/library/scala/concurrent/impl')
-rw-r--r-- | src/library/scala/concurrent/impl/ExecutionContextImpl.scala | 6 | ||||
-rw-r--r-- | src/library/scala/concurrent/impl/Future.scala | 2 | ||||
-rw-r--r-- | src/library/scala/concurrent/impl/Promise.scala | 16 |
3 files changed, 19 insertions, 5 deletions
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 7dc3ed2988..3ed960c7ab 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -10,10 +10,10 @@ package scala.concurrent.impl -import java.util.concurrent.{Callable, Executor, ExecutorService, Executors, ThreadFactory} +import java.util.concurrent.{ Callable, Executor, ExecutorService, Executors, ThreadFactory } import scala.concurrent.forkjoin._ -import scala.concurrent.{ExecutionContext, resolver, Awaitable} -import scala.concurrent.util.{ Duration } +import scala.concurrent.{ ExecutionContext, Awaitable } +import scala.concurrent.util.Duration diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala index 20d4122e8f..bf136b6195 100644 --- a/src/library/scala/concurrent/impl/Future.scala +++ b/src/library/scala/concurrent/impl/Future.scala @@ -57,7 +57,7 @@ private[concurrent] object Future { case NonFatal(e) => // Commenting out reporting for now, since it produces too much output in the tests //executor.reportFailure(e) - scala.concurrent.resolver(e) + Left(e) } } }) diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index da70b3dea5..5a5b893f16 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -11,7 +11,7 @@ package scala.concurrent.impl import java.util.concurrent.TimeUnit.{ NANOSECONDS, MILLISECONDS } -import scala.concurrent.{Awaitable, ExecutionContext, resolveEither, resolver, blocking, CanAwait, TimeoutException} +import scala.concurrent.{ Awaitable, ExecutionContext, blocking, CanAwait, TimeoutException, ExecutionException } //import scala.util.continuations._ import scala.concurrent.util.Duration import scala.util @@ -26,6 +26,20 @@ private[concurrent] trait Promise[T] extends scala.concurrent.Promise[T] with Fu object Promise { + + private def resolveEither[T](source: Either[Throwable, T]): Either[Throwable, T] = source match { + case Left(t) => resolver(t) + case _ => source + } + + private def resolver[T](throwable: Throwable): Either[Throwable, T] = throwable match { + case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value.asInstanceOf[T]) + case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) + case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) + case e: Error => Left(new ExecutionException("Boxed Error", e)) + case t => Left(t) + } + /** Default promise implementation. */ class DefaultPromise[T](implicit val executor: ExecutionContext) extends AbstractPromise with Promise[T] { self => |