Permalink
Browse files

Introducing tryCompleteWith for symmetry and for the possibility to t…

…reat racing completeWiths as a problem or not.
  • Loading branch information...
viktorklang committed Apr 15, 2012
1 parent 08cdc7b commit 578a62ff7ce3849e89b69dc4f5e725ea5eaedd26
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/library/scala/concurrent/Promise.scala
@@ -51,6 +51,15 @@ trait Promise[T] {
* @return This promise
*/
final def completeWith(other: Future[T]): this.type = {
+ other onComplete { this complete _ }
+ this
+ }
+
+ /** Attempts to complete this promise with the specified future, once that future is completed.
+ *
+ * @return This promise
+ */
+ final def tryCompleteWith(other: Future[T]): this.type = {
other onComplete { this tryComplete _ }
this
}

0 comments on commit 578a62f

Please sign in to comment.