DOC: Describe pattern.after, see #2410
This commit is contained in:
parent
7b45360b5f
commit
00f0d1f263
4 changed files with 50 additions and 0 deletions
|
|
@ -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) }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue