#19235 document fusing
This commit is contained in:
parent
a733096564
commit
939319e84d
5 changed files with 160 additions and 17 deletions
|
|
@ -220,4 +220,29 @@ class FlowDocSpec extends AkkaSpec {
|
|||
|
||||
//#flow-mat-combine
|
||||
}
|
||||
|
||||
"explicit fusing" in {
|
||||
//#explicit-fusing
|
||||
import akka.stream.Fusing
|
||||
|
||||
val flow = Flow[Int].map(_ * 2).filter(_ > 500)
|
||||
val fused = Fusing.aggressive(flow)
|
||||
|
||||
Source.fromIterator { () => Iterator from 0 }
|
||||
.via(fused)
|
||||
.take(1000)
|
||||
//#explicit-fusing
|
||||
}
|
||||
|
||||
"defining asynchronous boundaries" in {
|
||||
//#flow-async
|
||||
import akka.stream.Attributes.asyncBoundary
|
||||
|
||||
Source(List(1, 2, 3))
|
||||
.map(_ + 1)
|
||||
.withAttributes(asyncBoundary)
|
||||
.map(_ * 2)
|
||||
.to(Sink.ignore)
|
||||
//#flow-async
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue