diff options
author | aleksandar <aleksandar@lampmac14.epfl.ch> | 2011-12-12 19:59:41 +0100 |
---|---|---|
committer | aleksandar <aleksandar@lampmac14.epfl.ch> | 2011-12-12 19:59:41 +0100 |
commit | 9a04d0bea379c3fa12227493fddd0bffde9a569c (patch) | |
tree | a3fe41f9951cd771bbf44d28ece0cddd4e5467e5 /src | |
parent | 72424e397135bb9701e2fd4e36b2184b03586bd5 (diff) | |
download | scala-9a04d0bea379c3fa12227493fddd0bffde9a569c.tar.gz scala-9a04d0bea379c3fa12227493fddd0bffde9a569c.tar.bz2 scala-9a04d0bea379c3fa12227493fddd0bffde9a569c.zip |
Change promise fulfill and break to success and failure.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/concurrent/Blockable.scala | 1 | ||||
-rw-r--r-- | src/library/scala/concurrent/ExecutionContext.scala | 4 | ||||
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 28 | ||||
-rw-r--r-- | src/library/scala/concurrent/Promise.scala | 4 |
4 files changed, 20 insertions, 17 deletions
diff --git a/src/library/scala/concurrent/Blockable.scala b/src/library/scala/concurrent/Blockable.scala index 1ad02c7469..d5c45a9e4e 100644 --- a/src/library/scala/concurrent/Blockable.scala +++ b/src/library/scala/concurrent/Blockable.scala @@ -21,3 +21,4 @@ trait Blockable[+T] { + diff --git a/src/library/scala/concurrent/ExecutionContext.scala b/src/library/scala/concurrent/ExecutionContext.scala index 5d802d71b2..77d805b19c 100644 --- a/src/library/scala/concurrent/ExecutionContext.scala +++ b/src/library/scala/concurrent/ExecutionContext.scala @@ -1,11 +1,13 @@ package scala.concurrent + import java.util.concurrent.{ Executors, Future => JFuture, Callable } import scala.util.{ Duration, Timeout } import scala.concurrent.forkjoin.{ ForkJoinPool, RecursiveTask => FJTask, RecursiveAction, ForkJoinWorkerThread } + trait ExecutionContext { protected implicit object CanBlockEvidence extends CanBlock @@ -19,7 +21,7 @@ trait ExecutionContext { def future[T](body: Callable[T]): Future[T] = future(body.call()) def future[T](body: => T): Future[T] - + /** Only callable from the tasks running on the same execution context. */ def blockingCall[T](timeout: Timeout, body: Blockable[T]): T diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 1f44b50018..f653a8a47d 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -230,8 +230,8 @@ self => val p = newPromise[U] onComplete { - case Left(t) => if (pf isDefinedAt t) p fulfill pf(t) else p break t - case Right(v) => p fulfill v + case Left(t) => if (pf isDefinedAt t) p success pf(t) else p failure t + case Right(v) => p success v } p.future @@ -255,8 +255,8 @@ self => val p = newPromise[S] onComplete { - case Left(t) => p break t - case Right(v) => p fulfill f(v) + case Left(t) => p failure t + case Right(v) => p success f(v) } p.future @@ -273,10 +273,10 @@ self => val p = newPromise[S] onComplete { - case Left(t) => p break t + case Left(t) => p failure t case Right(v) => f(v) onComplete { - case Left(t) => p break t - case Right(v) => p fulfill v + case Left(t) => p failure t + case Right(v) => p success v } } @@ -303,8 +303,8 @@ self => val p = newPromise[T] onComplete { - case Left(t) => p break t - case Right(v) => if (pred(v)) p fulfill v else p break new NoSuchElementException("Future.filter predicate is not satisfied by: " + v) + case Left(t) => p failure t + case Right(v) => if (pred(v)) p success v else p failure new NoSuchElementException("Future.filter predicate is not satisfied by: " + v) } p.future @@ -320,18 +320,18 @@ object Future { val p: Promise[Coll[T]] = executionContext.promise[Coll[T]] if (futures.size == 1) futures.head onComplete { - case Left(t) => p break t + case Left(t) => p failure t case Right(v) => builder += v - p fulfill builder.result + p success builder.result } else { val restFutures = all(futures.tail) futures.head onComplete { - case Left(t) => p break t + case Left(t) => p failure t case Right(v) => builder += v restFutures onComplete { - case Left(t) => p break t + case Left(t) => p failure t case Right(vs) => for (v <- vs) builder += v - p fulfill builder.result + p success builder.result } } } diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala index fb80eb8f31..aae0135af4 100644 --- a/src/library/scala/concurrent/Promise.scala +++ b/src/library/scala/concurrent/Promise.scala @@ -38,7 +38,7 @@ trait Promise[T] { * * $promiseCompletion */ - def fulfill(value: T): Unit + def success(value: T): Unit /** Completes the promise with an exception. * @@ -48,7 +48,7 @@ trait Promise[T] { * * $promiseCompletion */ - def break(t: Throwable): Unit + def failure(t: Throwable): Unit /** Wraps a `Throwable` in an `ExecutionException` if necessary. * |