Permalink
Browse files

Rewriting the doc message for tryAddCallback so it reflects the seman…

…tics
  • Loading branch information...
viktorklang committed Apr 15, 2012
1 parent a5d1ac7 commit 611be28bb27ed0afd5da54f684d6b1aa7067ba87
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/library/scala/concurrent/impl/Promise.scala
@@ -110,14 +110,13 @@ object Promise {
}
def onComplete[U](func: Either[Throwable, T] => U): this.type = {
@tailrec //Returns whether the future has already been completed or not
def tryAddCallback(): Either[Throwable, T] = {
val cur = getState
cur match {
@tailrec //Returns null if callback was added and the result if the promise was already completed
def tryAddCallback(): Either[Throwable, T] =
getState match {
case r: Either[_, _] => r.asInstanceOf[Either[Throwable, T]]
case listeners: List[_] => if (updateState(listeners, func :: listeners)) null else tryAddCallback()
}
}
tryAddCallback() match {
case null => this

0 comments on commit 611be28

Please sign in to comment.