Created
March 21, 2023 20:29
-
-
Save samspills/9fba844bda2e18940740c18fed1a5dca to your computer and use it in GitHub Desktop.
example for #3506
This file contains 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
//> 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