DOC: Describe pattern.after, see #2410

This commit is contained in:
Patrik Nordwall 2012-08-20 19:49:01 +02:00
parent 7b45360b5f
commit 00f0d1f263
4 changed files with 50 additions and 0 deletions

View file

@ -377,4 +377,16 @@ class FutureDocSpec extends AkkaSpec {
intercept[IllegalArgumentException] { Await.result(otherFuture, 1 second) }
}
"demonstrate usage of pattern.after" in {
//#after
import akka.pattern.after
val delayed = after(500 millis, using = system.scheduler)(Promise.failed(
new IllegalStateException("OHNOES")).future)
val future = Future { Thread.sleep(1000); "foo" }
val result = Future.firstCompletedOf(Seq(Promise[String]().future, delayed))
//#after
intercept[IllegalStateException] { Await.result(result, 2 second) }
}
}