summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/Future.scala
diff options
context:
space:
mode:
authorAleksandar Prokopec <aleksandar.prokopec@gmail.com>2011-12-07 16:52:08 +0100
committerAleksandar Prokopec <aleksandar.prokopec@gmail.com>2011-12-07 16:52:08 +0100
commitcbad136be350087ebb29b9a36c1da893bbb18ec9 (patch)
treee0a949f2ac39bb5313b5b018c95bbfe28ffcc102 /src/library/scala/concurrent/Future.scala
parentcb8e0de9538ec57a90fd71c47e20b7319c4904cc (diff)
downloadscala-cbad136be350087ebb29b9a36c1da893bbb18ec9.tar.gz
scala-cbad136be350087ebb29b9a36c1da893bbb18ec9.tar.bz2
scala-cbad136be350087ebb29b9a36c1da893bbb18ec9.zip
Minor changes with the docs.
Diffstat (limited to 'src/library/scala/concurrent/Future.scala')
-rw-r--r--src/library/scala/concurrent/Future.scala22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 5f64c2fc1a..9c1b8b4cd1 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -38,12 +38,12 @@ import java.util.concurrent.atomic.{ AtomicReferenceFieldUpdater, AtomicInteger,
* @define caughtThrowables
* The future may contain a throwable object and this means that the future failed.
* Futures obtained through combinators have the same exception as the future they were obtained from.
- * The following throwable objects are not caught by the future:
+ * The following throwable objects are not contained in the future:
* - Error - errors are not contained within futures
- * - scala.util.control.ControlException - not contained within futures
+ * - scala.util.control.ControlThrowable - not contained within futures
* - InterruptedException - not contained within futures
*
- * Instead, the future is completed with a NoSuchElementException with one of the exceptions above
+ * Instead, the future is completed with a ExecutionException with one of the exceptions above
* as the cause.
*
* @define forComprehensionExamples
@@ -59,7 +59,7 @@ import java.util.concurrent.atomic.{ AtomicReferenceFieldUpdater, AtomicInteger,
* }}}
*
* is translated to:
- *
+ *
* {{{
* f flatMap { (x: Int) => g map { (y: Int) => x + y } }
* }}}
@@ -85,8 +85,8 @@ self =>
}
/** When this future is completed with a failure (i.e. with a throwable),
- * apply the provided function to the throwable.
- *
+ * apply the provided callback to the throwable.
+ *
* $caughtThrowables
*
* If the future has already been completed with a failure,
@@ -98,9 +98,8 @@ self =>
*
* $multipleCallbacks
*/
- def onFailure[U](callback: Throwable => U): this.type = onComplete {
- case Left(te: FutureTimeoutException) => callback(te)
- case Left(t) if isFutureThrowable(t) => callback(t)
+ def onFailure[U](callback: PartialFunction[Throwable, U]): this.type = onComplete {
+ case Left(t) if t.isInstanceOf[FutureTimeoutException] || isFutureThrowable(t) => if (callback.isDefinedAt(t)) callback(t)
case Right(v) => // do nothing
}
@@ -161,6 +160,9 @@ self =>
/* Projections */
+ /** A failed projection of the future.
+ *
+ */
def failed: Future[Throwable] = new Future[Throwable] {
def executionContext = self.executionContext
def onComplete[U](func: Either[Throwable, Throwable] => U) = {
@@ -182,6 +184,8 @@ self =>
new NoSuchElementException("Future.failed not completed with a throwable. Instead completed with: " + v)
}
+ /** A timed out projection of the future.
+ */
def timedout: Future[FutureTimeoutException] = new Future[FutureTimeoutException] {
def executionContext = self.executionContext
def onComplete[U](func: Either[Throwable, FutureTimeoutException] => U) = {