Created
December 29, 2022 11:54
-
-
Save qingwei91/ee889205ddceda2f559b83d497dc0b2e to your computer and use it in GitHub Desktop.
Low level IO api
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
import cats.effect._ | |
val a = IO(...) | |
// get access to underlying thread-like abstraction, where you can cancel, cancel is however asynchronous! | |
val aFiber = a.start | |
val cancel = aFiber.flatMap(_.cancel) | |
val join = aFiber.flatMap(_.join) | |
IO.race(cancel, join) // try to cancel and join concurrently, non-deterministic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment