add Futures.promise to the docs

This commit is contained in:
Roland 2013-05-09 21:48:08 +02:00
parent 325ea283cb
commit e6655ec157
4 changed files with 25 additions and 2 deletions

View file

@ -399,15 +399,21 @@ class FutureDocSpec extends AkkaSpec {
}
}
"demonstrate usage of Future.successful & Future.failed" in {
"demonstrate usage of Future.successful & Future.failed & Future.promise" in {
//#successful
val future = Future.successful("Yay!")
//#successful
//#failed
val otherFuture = Future.failed[String](new IllegalArgumentException("Bang!"))
//#failed
//#promise
val promise = Promise[String]()
val theFuture = promise.future
promise.success("hello")
//#promise
Await.result(future, 3 seconds) must be("Yay!")
intercept[IllegalArgumentException] { Await.result(otherFuture, 3 seconds) }
Await.result(theFuture, 3 seconds) must be("hello")
}
"demonstrate usage of pattern.after" in {