Scala Cats Effects - IO Async Shift - How Does it Work?
问题 Here is some Scala cats code using the IO Monad: import java.util.concurrent.{ExecutorService, Executors} import cats.effect.IO import scala.concurrent.{ExecutionContext, ExecutionContextExecutor} import scala.util.control.NonFatal object Program extends App { type CallbackType = (Either[Throwable, Unit]) => Unit // IO.async[Unit] is like a Future that returns Unit on completion. // Unlike a regular Future, it doesn't start to run until unsafeRunSync is called. def forkAsync(toRun: () => Unit