diff options
author | Philipp Haller <hallerp@gmail.com> | 2011-12-07 16:52:20 +0100 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2011-12-07 16:52:20 +0100 |
commit | 91b6028fd3b728f59fb38cd3e12e25a2120ebb16 (patch) | |
tree | c78160bc8fe67f144e73ac2b789d54f8e0949361 | |
parent | 4ea25c98d377b6b0369fa20aa9d4bfd3a3223ef6 (diff) | |
parent | cb8e0de9538ec57a90fd71c47e20b7319c4904cc (diff) | |
download | scala-91b6028fd3b728f59fb38cd3e12e25a2120ebb16.tar.gz scala-91b6028fd3b728f59fb38cd3e12e25a2120ebb16.tar.bz2 scala-91b6028fd3b728f59fb38cd3e12e25a2120ebb16.zip |
Merge branch 'execution-context' of https://github.com/phaller/scala into execution-context
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index eff155f5e9..5f64c2fc1a 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -38,10 +38,13 @@ 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 treated differently: + * The following throwable objects are not caught by the future: * - Error - errors are not contained within futures * - scala.util.control.ControlException - not contained within futures * - InterruptedException - not contained within futures + * + * Instead, the future is completed with a NoSuchElementException with one of the exceptions above + * as the cause. * * @define forComprehensionExamples * Example: @@ -95,8 +98,9 @@ self => * * $multipleCallbacks */ - def onFailure[U](func: Throwable => U): this.type = onComplete { - case Left(t) if isFutureThrowable(t) => func(t) + def onFailure[U](callback: Throwable => U): this.type = onComplete { + case Left(te: FutureTimeoutException) => callback(te) + case Left(t) if isFutureThrowable(t) => callback(t) case Right(v) => // do nothing } @@ -107,8 +111,8 @@ self => * * $multipleCallbacks */ - def onTimeout[U](body: FutureTimeoutException => U): this.type = onComplete { - case Left(te: FutureTimeoutException) => body(te) + def onTimeout[U](callback: FutureTimeoutException => U): this.type = onComplete { + case Left(te: FutureTimeoutException) => callback(te) case Right(v) => // do nothing } |