Skip to content

Different performance between Scala2 and Scala3 in async[Resource[IO, *]] #77

Description

@djx314
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions