diff options
author | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-23 15:20:02 +0100 |
---|---|---|
committer | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-23 15:20:02 +0100 |
commit | 645cb791cf032d464de6a3a0d8e7ee1ae4ffe73c (patch) | |
tree | 348249818d41ff895a432fc639fe9dd6305a81dd /src/library | |
parent | da3fce49d2dae2b883a8147c63d8da3b845663d2 (diff) | |
download | scala-645cb791cf032d464de6a3a0d8e7ee1ae4ffe73c.tar.gz scala-645cb791cf032d464de6a3a0d8e7ee1ae4ffe73c.tar.bz2 scala-645cb791cf032d464de6a3a0d8e7ee1ae4ffe73c.zip |
Fixed the way callbacks are handled. Removed executor from base future trait.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 8 | ||||
-rw-r--r-- | src/library/scala/concurrent/Promise.scala | 4 | ||||
-rw-r--r-- | src/library/scala/concurrent/akka/Promise.scala | 13 | ||||
-rw-r--r-- | src/library/scala/concurrent/default/TaskImpl.scala | 2 |
4 files changed, 13 insertions, 14 deletions
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] |