Created
October 10, 2018 13:14
-
-
Save lysebraate/70ce4e9ae1539f04895fff08df8ede7e to your computer and use it in GitHub Desktop.
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
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