Skip to content

Instantly share code, notes, and snippets.

@zainab-ali
Created June 23, 2025 17:04
Show Gist options
  • Save zainab-ali/fb78a2b8173c9e1105a30a968c2209e9 to your computer and use it in GitHub Desktop.
Save zainab-ali/fb78a2b8173c9e1105a30a968c2209e9 to your computer and use it in GitHub Desktop.
aquascape: metered & parEvalMapUnorderedUnbounded
//> using scala "3.7.0"
//> using dep "com.github.zainab-ali::aquascape::0.4.0"
import fs2.*
import cats.effect.*
import aquascape.*
import aquascape.drawing.*
import scala.concurrent.duration.*
object MeteredParEvalMapUnbounded extends AquascapeApp {
override def config: Config = super.config.scale(4)
def name: String = "aquascape"
def stream(using Scape[IO]): IO[Unit] = {
Stream('a', 'b', 'c', 'd')
.stage("input", "upstream")
.metered(1.second)
.stage("metered(1s)", "upstream")
.fork("root", "upstream")
.parEvalMapUnorderedUnbounded(c => IO.sleep(3.seconds).as(c))
.stage("parEvalMapUnorderedUnbounded(sleep(3s))")
.compile
.drain
.compileStage("output")
.void
}
}
@zainab-ali
Copy link
Author

Run with scala-cli https://gist.github.com/zainab-ali/fb78a2b8173c9e1105a30a968c2209e9 and open aquscape.png:

image

Learn how to read he aquascapes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment