diff options
author | James Iry <jamesiry@gmail.com> | 2013-11-12 15:56:32 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-11-12 15:56:32 -0800 |
commit | 5cef951d0d230cfecd1138a0cc18643052437100 (patch) | |
tree | c2a8d159f78357dfd14295aaebd999140d7f6ab7 /src/library | |
parent | d2cee3a5e1d26ba27fd7912d48b1e7af0beb844a (diff) | |
parent | aac015a84c2d64ce485078a5a854bc7533e2fc7b (diff) | |
download | scala-5cef951d0d230cfecd1138a0cc18643052437100.tar.gz scala-5cef951d0d230cfecd1138a0cc18643052437100.tar.bz2 scala-5cef951d0d230cfecd1138a0cc18643052437100.zip |
Merge pull request #3111 from phaller/issue/7958
SI-7958 Deprecate methods `future` and `promise` in the `scala.concurren...
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 28 | ||||
-rw-r--r-- | src/library/scala/concurrent/package.scala | 4 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index b9f73c2872..dd86af0dd4 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -29,11 +29,11 @@ import scala.reflect.ClassTag /** The trait that represents futures. * - * Asynchronous computations that yield futures are created with the `future` call: + * Asynchronous computations that yield futures are created with the `Future` call: * * {{{ * val s = "Hello" - * val f: Future[String] = future { + * val f: Future[String] = Future { * s + " future!" * } * f onSuccess { @@ -67,8 +67,8 @@ import scala.reflect.ClassTag * Example: * * {{{ - * val f = future { 5 } - * val g = future { 3 } + * val f = Future { 5 } + * val g = Future { 3 } * val h = for { * x: Int <- f // returns Future(5) * y: Int <- g // returns Future(3) @@ -266,7 +266,7 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { 5 } + * val f = Future { 5 } * val g = f filter { _ % 2 == 1 } * val h = f filter { _ % 2 == 0 } * Await.result(g, Duration.Zero) // evaluates to 5 @@ -291,7 +291,7 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { -5 } + * val f = Future { -5 } * val g = f collect { * case x if x < 0 => -x * } @@ -314,9 +314,9 @@ trait Future[+T] extends Awaitable[T] { * Example: * * {{{ - * future (6 / 0) recover { case e: ArithmeticException => 0 } // result: 0 - * future (6 / 0) recover { case e: NotFoundException => 0 } // result: exception - * future (6 / 2) recover { case e: ArithmeticException => 0 } // result: 3 + * Future (6 / 0) recover { case e: ArithmeticException => 0 } // result: 0 + * Future (6 / 0) recover { case e: NotFoundException => 0 } // result: exception + * Future (6 / 2) recover { case e: ArithmeticException => 0 } // result: 3 * }}} */ def recover[U >: T](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U] = { @@ -334,8 +334,8 @@ trait Future[+T] extends Awaitable[T] { * Example: * * {{{ - * val f = future { Int.MaxValue } - * future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue + * val f = Future { Int.MaxValue } + * Future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue * }}} */ def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]])(implicit executor: ExecutionContext): Future[U] = { @@ -373,8 +373,8 @@ trait Future[+T] extends Awaitable[T] { * * Example: * {{{ - * val f = future { sys.error("failed") } - * val g = future { 5 } + * val f = Future { sys.error("failed") } + * val g = Future { 5 } * val h = f fallbackTo g * Await.result(h, Duration.Zero) // evaluates to 5 * }}} @@ -416,7 +416,7 @@ trait Future[+T] extends Awaitable[T] { * The following example prints out `5`: * * {{{ - * val f = future { 5 } + * val f = Future { 5 } * f andThen { * case r => sys.error("runtime exception") * } andThen { diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala index 2fe14a9c1a..cc1350f5a9 100644 --- a/src/library/scala/concurrent/package.scala +++ b/src/library/scala/concurrent/package.scala @@ -27,6 +27,8 @@ package object concurrent { * @param executor the execution context on which the future is run * @return the `Future` holding the result of the computation */ + @deprecated("Use `Future { ... }` instead.", "2.11.0") + // removal planned for 2.13.0 def future[T](body: =>T)(implicit @deprecatedName('execctx) executor: ExecutionContext): Future[T] = Future[T](body) /** Creates a promise object which can be completed with a value or an exception. @@ -34,6 +36,8 @@ package object concurrent { * @tparam T the type of the value in the promise * @return the newly created `Promise` object */ + @deprecated("Use `Promise[T]()` instead.", "2.11.0") + // removal planned for 2.13.0 def promise[T](): Promise[T] = Promise[T]() /** Used to designate a piece of code which potentially blocks, allowing the current [[BlockContext]] to adjust |