From 645cb791cf032d464de6a3a0d8e7ee1ae4ffe73c Mon Sep 17 00:00:00 2001 From: aleksandar Date: Mon, 23 Jan 2012 15:20:02 +0100 Subject: Fixed the way callbacks are handled. Removed executor from base future trait. --- src/library/scala/concurrent/Future.scala | 8 ++------ src/library/scala/concurrent/Promise.scala | 4 ++-- src/library/scala/concurrent/akka/Promise.scala | 13 +++++++------ src/library/scala/concurrent/default/TaskImpl.scala | 2 ++ 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 4f89aa483d..a22f67d45d 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -128,13 +128,9 @@ self => /* Miscellaneous */ - /** The execution context of the future. - */ - def executor: ExecutionContext - /** Creates a new promise. */ - def newPromise[S]: Promise[S] = executor promise + def newPromise[S]: Promise[S] /* Projections */ @@ -152,7 +148,7 @@ self => * and throws a corresponding exception if the original future fails. */ def failed: Future[Throwable] = new Future[Throwable] { - def executor = self.executor + def newPromise[S]: Promise[S] = self.newPromise def onComplete[U](func: Either[Throwable, Throwable] => U) = { self.onComplete { case Left(t) => func(Right(t)) diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala index 6aa04eff9f..669025699a 100644 --- a/src/library/scala/concurrent/Promise.scala +++ b/src/library/scala/concurrent/Promise.scala @@ -101,8 +101,8 @@ trait Promise[T] { @implicitNotFound(msg = "Calling this method yields non-deterministic programs.") def tryFailure(t: Throwable)(implicit nondet: NonDeterministic): Boolean = tryComplete(Left(t))(nonDeterministicEvidence) - /** Wraps a `Throwable` in an `ExecutionException` if necessary. - * + /** Wraps a `Throwable` in an `ExecutionException` if necessary. TODO replace with `resolver` from scala.concurrent + * * $allowedThrowables */ protected def wrap(t: Throwable): Throwable = t match { diff --git a/src/library/scala/concurrent/akka/Promise.scala b/src/library/scala/concurrent/akka/Promise.scala index e36d237e82..340b40bf74 100644 --- a/src/library/scala/concurrent/akka/Promise.scala +++ b/src/library/scala/concurrent/akka/Promise.scala @@ -23,6 +23,8 @@ trait Promise[T] extends scala.concurrent.Promise[T] with Future[T] { def future = this + def newPromise[S]: Promise[S] = executor promise + // TODO refine answer and return types here from Any to type parameters // then move this up in the hierarchy /* @@ -194,12 +196,11 @@ object Promise { } private final def notifyCompleted(func: Either[Throwable, T] => Any, result: Either[Throwable, T]) { - // TODO see what to do about logging - //try { - func(result) - //} catch { - // case e => logError("Future onComplete-callback raised an exception", e) - //} + try { + func(result) + } catch { + case e => e.printStackTrace() + } } } diff --git a/src/library/scala/concurrent/default/TaskImpl.scala b/src/library/scala/concurrent/default/TaskImpl.scala index 771cf02ec1..227d9d48cd 100644 --- a/src/library/scala/concurrent/default/TaskImpl.scala +++ b/src/library/scala/concurrent/default/TaskImpl.scala @@ -16,6 +16,8 @@ self: Future[T] => val executor: ExecutionContextImpl + def newPromise[S]: Promise[S] = executor promise + type Callback = Either[Throwable, T] => Any def getState: State[T] -- cgit v1.2.3