Last active
August 4, 2016 16:25
-
-
Save mkows/a9d5bb36d74e91591b13198239699851 to your computer and use it in GitHub Desktop.
fs2 big-bang vs sequential processing of Seq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Fs2GuideApp extends App { | |
import fs2.Stream | |
import fs2.Task | |
def printTask(i: Int): Task[Boolean] = { | |
Task.delay { | |
println(s"started: $i") | |
Thread.sleep(200) | |
println(s"ended__: $i") | |
true | |
} | |
} | |
val input = (1 to 20).toList | |
val x = Stream.emits(input).map { i => // compare with -> val x = Stream.emits(input).unchunk.map { i => | |
printTask(i).map { | |
case res if i < 3 => !res | |
case res if i >= 3 => res | |
} | |
}.flatMap(Stream.eval) | |
val res = x.runLog.unsafeRun() | |
println(s"res = $res") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unchunk
):