summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeather Miller <heather.miller@epfl.ch>2012-10-10 11:59:54 +0200
committerHeather Miller <heather.miller@epfl.ch>2012-10-10 11:59:54 +0200
commitbc25fc53ade2131a2717b3101a01abbbfcbdf646 (patch)
tree3db128694685ebdd89480b6e8cca136949425314
parent36e56bca7f96eca3c7c11118aada32b5f37621c0 (diff)
downloadscala-bc25fc53ade2131a2717b3101a01abbbfcbdf646.tar.gz
scala-bc25fc53ade2131a2717b3101a01abbbfcbdf646.tar.bz2
scala-bc25fc53ade2131a2717b3101a01abbbfcbdf646.zip
SI-6099 - Scaladoc for scala.concurrent incomplete
This is a rebase and resubmission of @phaller's pull https://github.com/scala/scala/pull/1485 With the reviewers' comments additionally addressed
-rw-r--r--build.xml2
-rw-r--r--src/library/scala/concurrent/Awaitable.scala55
-rw-r--r--src/library/scala/concurrent/package.scala70
3 files changed, 70 insertions, 57 deletions
diff --git a/build.xml b/build.xml
index 9109da5276..c9027e0985 100644
--- a/build.xml
+++ b/build.xml
@@ -2337,7 +2337,7 @@ DOCUMENTATION
docfooter="epfl"
docsourceurl="${scaladoc.url}€{FILE_PATH}.scala#L1"
docUncompilable="${src.dir}/library-aux"
- skipPackages="scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
+ skipPackages="scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io:scala.concurrent.impl"
sourcepath="${src.dir}"
classpathref="pack.classpath"
addparams="${scalac.args.all}"
diff --git a/src/library/scala/concurrent/Awaitable.scala b/src/library/scala/concurrent/Awaitable.scala
index 3bd7617bce..c0c688bf42 100644
--- a/src/library/scala/concurrent/Awaitable.scala
+++ b/src/library/scala/concurrent/Awaitable.scala
@@ -14,36 +14,47 @@ import scala.concurrent.duration.Duration
+/**
+ * An object that may eventually be completed with a result value of type `T` which may be
+ * awaited using blocking methods.
+ *
+ * The [[Await]] object provides methods that allow accessing the result of an `Awaitable`
+ * by blocking the current thread until the `Awaitable` has been completed or a timeout has
+ * occurred.
+ */
trait Awaitable[+T] {
+
/**
- * Await the "resolved" state of this Awaitable.
- * This method should not be called directly.
- *
- * @param atMost
- * maximum wait time, which may be negative (no waiting is done),
- * [[Duration.Inf]] for unbounded waiting, or a finite positive
- * duration
- * @return the Awaitable itself
- * @throws InterruptedException if the wait call was interrupted
- * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready
- * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
+ * Await the "completed" state of this `Awaitable`.
+ *
+ * '''''This method should not be called directly; use [[Await.ready]] instead.'''''
+ *
+ * @param atMost
+ * maximum wait time, which may be negative (no waiting is done),
+ * [[scala.concurrent.duration.Duration.Inf Duration.Inf]] for unbounded waiting, or a finite positive
+ * duration
+ * @return this `Awaitable`
+ * @throws InterruptedException if the current thread is interrupted while waiting
+ * @throws TimeoutException if after waiting for the specified time this `Awaitable` is still not ready
+ * @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
*/
@throws(classOf[TimeoutException])
@throws(classOf[InterruptedException])
def ready(atMost: Duration)(implicit permit: CanAwait): this.type
/**
- * Await and return the result of this Awaitable, which is either of type T or a thrown exception (any Throwable).
- * This method should not be called directly.
- *
- * @param atMost
- * maximum wait time, which may be negative (no waiting is done),
- * [[Duration.Inf]] for unbounded waiting, or a finite positive
- * duration
- * @return the value if the Awaitable was successful within the specific maximum wait time
- * @throws InterruptedException if the wait call was interrupted
- * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready
- * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
+ * Await and return the result (of type `T`) of this `Awaitable`.
+ *
+ * '''''This method should not be called directly; use [[Await.result]] instead.'''''
+ *
+ * @param atMost
+ * maximum wait time, which may be negative (no waiting is done),
+ * [[scala.concurrent.duration.Duration.Inf Duration.Inf]] for unbounded waiting, or a finite positive
+ * duration
+ * @return the result value if the `Awaitable` is completed within the specific maximum wait time
+ * @throws InterruptedException if the current thread is interrupted while waiting
+ * @throws TimeoutException if after waiting for the specified time this `Awaitable` is still not ready
+ * @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
*/
@throws(classOf[Exception])
def result(atMost: Duration)(implicit permit: CanAwait): T
diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala
index e683732e41..c0d46df883 100644
--- a/src/library/scala/concurrent/package.scala
+++ b/src/library/scala/concurrent/package.scala
@@ -23,7 +23,7 @@ package object concurrent {
* The result becomes available once the asynchronous computation is completed.
*
* @tparam T the type of the result
- * @param body the asychronous computation
+ * @param body the asynchronous computation
* @param execctx the execution context on which the future is run
* @return the `Future` holding the result of the computation
*/
@@ -37,17 +37,15 @@ package object concurrent {
*/
def promise[T]()(implicit execctx: ExecutionContext): Promise[T] = Promise[T]()
- /** Used to designate a piece of code which potentially blocks, allowing the BlockContext to adjust the runtime's behavior.
+ /** Used to designate a piece of code which potentially blocks, allowing the current [[BlockContext]] to adjust
+ * the runtime's behavior.
* Properly marking blocking code may improve performance or avoid deadlocks.
*
- * If you have an `Awaitable` then you should use Await.result instead of `blocking`.
+ * Blocking on an [[Awaitable]] should be done using [[Await.result]] instead of `blocking`.
*
* @param body A piece of code which contains potentially blocking or long running calls.
- *
- * Calling this method may throw the following exceptions:
- * - CancellationException - if the computation was cancelled
- * - InterruptedException - in the case that a wait within the blockable object was interrupted
- * - TimeoutException - in the case that the blockable object timed out
+ * @throws `CancellationException` if the computation was cancelled
+ * @throws `InterruptedException` in the case that a wait within the blocking `body` was interrupted
*/
@throws(classOf[Exception])
def blocking[T](body: =>T): T = BlockContext.current.blockOn(body)(scala.concurrent.AwaitPermission)
@@ -67,19 +65,21 @@ package concurrent {
*/
object Await {
/**
- * Await the "resolved" state of this Awaitable.
- * Invokes ready() on the awaitable, properly wrapped by a call to `scala.concurrent.blocking`.
- *
- * @param awaitable
- * the `Awaitable` on which `ready` is to be called
- * @param atMost
- * maximum wait time, which may be negative (no waiting is done),
- * [[Duration.Inf]] for unbounded waiting, or a finite positive
- * duration
- * @return the awaitable itself
- * @throws InterruptedException if the wait call was interrupted
- * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready
- * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
+ * Await the "completed" state of an `Awaitable`.
+ *
+ * Although this method is blocking, the internal use of [[scala.concurrent.blocking blocking]] ensures that
+ * the underlying [[ExecutionContext]] is prepared to properly manage the blocking.
+ *
+ * @param awaitable
+ * the `Awaitable` to be awaited
+ * @param atMost
+ * maximum wait time, which may be negative (no waiting is done),
+ * [[scala.concurrent.duration.Duration.Inf Duration.Inf]] for unbounded waiting, or a finite positive
+ * duration
+ * @return the `awaitable`
+ * @throws InterruptedException if the current thread is interrupted while waiting
+ * @throws TimeoutException if after waiting for the specified time this `Awaitable` is still not ready
+ * @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
*/
@throws(classOf[TimeoutException])
@throws(classOf[InterruptedException])
@@ -87,19 +87,21 @@ package concurrent {
blocking(awaitable.ready(atMost)(AwaitPermission))
/**
- * Await and return the result of this Awaitable, which is either of type T or a thrown exception (any Throwable).
- * Invokes result() on the awaitable, properly wrapped by a call to `scala.concurrent.blocking`.
- *
- * @param awaitable
- * the `Awaitable` on which `result` is to be called
- * @param atMost
- * maximum wait time, which may be negative (no waiting is done),
- * [[Duration.Inf]] for unbounded waiting, or a finite positive
- * duration
- * @return the value if the Awaitable was successful within the specific maximum wait time
- * @throws InterruptedException if the wait call was interrupted
- * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready
- * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
+ * Await and return the result (of type `T`) of an `Awaitable`.
+ *
+ * Although this method is blocking, the internal use of [[scala.concurrent.blocking blocking]] ensures that
+ * the underlying [[ExecutionContext]] to properly detect blocking and ensure that there are no deadlocks.
+ *
+ * @param awaitable
+ * the `Awaitable` to be awaited
+ * @param atMost
+ * maximum wait time, which may be negative (no waiting is done),
+ * [[scala.concurrent.duration.Duration.Inf Duration.Inf]] for unbounded waiting, or a finite positive
+ * duration
+ * @return the result value if `awaitable` is completed within the specific maximum wait time
+ * @throws InterruptedException if the current thread is interrupted while waiting
+ * @throws TimeoutException if after waiting for the specified time `awaitable` is still not ready
+ * @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
*/
@throws(classOf[Exception])
def result[T](awaitable: Awaitable[T], atMost: Duration): T =