Skip to content

Instantly share code, notes, and snippets.

@samspills
Created March 21, 2023 20:29
Show Gist options
  • Save samspills/9fba844bda2e18940740c18fed1a5dca to your computer and use it in GitHub Desktop.
Save samspills/9fba844bda2e18940740c18fed1a5dca to your computer and use it in GitHub Desktop.
example for #3506
//> using lib "org.typelevel::cats-effect:3.4.8"
import cats.effect.{IO, IOApp}
import cats.effect.std.Dispatcher
import scala.concurrent.duration._
object Example extends IOApp.Simple {
def run: IO[Unit] =
Dispatcher.parallel[IO](await = true).use { dispatcher =>
for {
_ <- IO(dispatcher.unsafeRunAndForget(IO.print(" Scalar 2023").delayBy(5.millis)))
_ <- IO(dispatcher.unsafeRunAndForget(IO.print("Hello")))
// _ <- IO.sleep(100.millis)
} yield ()
} *> IO.blocking(System.out.flush())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment