Skip to content

Instantly share code, notes, and snippets.

@qingwei91
Created December 29, 2022 11:54
Show Gist options
  • Save qingwei91/ee889205ddceda2f559b83d497dc0b2e to your computer and use it in GitHub Desktop.
Save qingwei91/ee889205ddceda2f559b83d497dc0b2e to your computer and use it in GitHub Desktop.
Low level IO api
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