Skip to content

Instantly share code, notes, and snippets.

@lysebraate
Created October 10, 2018 13:14
Show Gist options
  • Save lysebraate/70ce4e9ae1539f04895fff08df8ede7e to your computer and use it in GitHub Desktop.
Save lysebraate/70ce4e9ae1539f04895fff08df8ede7e to your computer and use it in GitHub Desktop.
package no.arktekk.purely.catseffect
import org.scalatest.FunSuite
import cats.{Parallel, effect}
import cats.implicits._
import cats.effect.implicits._
import cats.effect.internals.IOContextShift
import cats.effect.{ContextShift, IO}
class CatsEffectIOAsyncTest extends FunSuite {
test("") {
//implicit val contextShift = IOContextShift.global
implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
implicit val ctxShift: ContextShift[IO] = IO.contextShift(ec)
//implicit val a: Parallel[IO, effect.IO.Par] = IO.ioParallel
val ios: List[IO[Int]] = (0 until 10).map(a => {
IO {
Thread.sleep(4000)
println(s"Running ${a} from ${Thread.currentThread().getName}")
a
}
}).toList
val b: IO[List[Int]] = ios.parSequence
b.unsafeRunSync()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment