summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/Promise.scala
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-03-28 19:17:49 +0200
committerAleksandar Prokopec <axel22@gmail.com>2012-03-28 19:17:49 +0200
commit47318105010786bc6eba835c957ce3cd4fe88d70 (patch)
tree2fe3398daaf39ad0c6e292e7a3656d8058ce15e0 /src/library/scala/concurrent/Promise.scala
parent3e40fb5d94a4d185c93861b9caf86ac92a04ef2a (diff)
downloadscala-47318105010786bc6eba835c957ce3cd4fe88d70.tar.gz
scala-47318105010786bc6eba835c957ce3cd4fe88d70.tar.bz2
scala-47318105010786bc6eba835c957ce3cd4fe88d70.zip
Work on source compatibility between akka and scala futures.
Removed some methods from execution contexts. Changed Awaitable interface.
Diffstat (limited to 'src/library/scala/concurrent/Promise.scala')
-rw-r--r--src/library/scala/concurrent/Promise.scala16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala
index 4404e90971..61e21606e6 100644
--- a/src/library/scala/concurrent/Promise.scala
+++ b/src/library/scala/concurrent/Promise.scala
@@ -30,8 +30,6 @@ import scala.util.{ Try, Success, Failure }
*/
trait Promise[T] {
- import nondeterministic._
-
/** Future containing the value of this promise.
*/
def future: Future[T]
@@ -114,12 +112,18 @@ trait Promise[T] {
object Promise {
- def kept[T](result: T)(implicit execctx: ExecutionContext): Promise[T] =
- execctx keptPromise result
+ /** Creates a new promise.
+ */
+ def apply[T]()(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.DefaultPromise[T]()
- def broken[T](t: Throwable)(implicit execctx: ExecutionContext): Promise[T] =
- execctx brokenPromise t
+ /** Creates an already completed Promise with the specified exception
+ */
+ def failed[T](exception: Throwable)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Failure(exception))
+ /** Creates an already completed Promise with the specified result
+ */
+ def successful[T](result: T)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Success(result))
+
}