val resource1 = async[Resource[IO, *]] {
r1.await
}
val resource2 = async[Resource[IO, *]] {
r2.await
}
val http4sServerResource = for {
r1 <- resource1
r2 <- resource2
} yield r1.exec(r2)
def run(args: List[String]): IO[ExitCode] = http4sServerResource.useForever.as(ExitCode.Success)
It seems that resource1 and resource2 is already use when the block of async { } is ended. So when r1.exec(r2) the resource is closed.
And in Scala3 r1.exec(r2) can exec succeed.
It seems that
resource1andresource2is alreadyusewhen the block of async { } is ended. So whenr1.exec(r2)the resource is closed.And in Scala3
r1.exec(r2)can exec succeed.