Created
May 28, 2018 16:17
-
-
Save kevinmeredith/1812c2bc221a5adc8bae0f29104cc4e5 to your computer and use it in GitHub Desktop.
Revisions
-
kevinmeredith created this gist
May 28, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ @ import $ivy.`org.typelevel::cats-effect:0.10.1` @ import cats._, cats.data._, cats.implicits._, cats.effect._ @ def lift(i: Int): IO[Int] = Timer[IO].sleep(1.second) >> IO { println(Thread.currentThread.getName + "At time = " + java.time.Instant.now) i } @ (0 to 10).toList.map(i => Concurrent[IO].start(lift(i))) res41: List[IO[Fiber[IO, Int]]] = List( Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@2faeea2), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@3e8c8be5), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@108a2dcd), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@d21918f), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@58fbe177), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@2729a2e), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@43d73be8), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@427b77f4), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@450cd695), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@533987f0), Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@29cbfe04) ) @ Traverse[List].sequence(res41) res42: IO[List[Fiber[IO, Int]]] = Map( Bind(Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@2faeea2), cats.FlatMap$$Lambda$2914/1434934951@60e127c1), scala.Function2$$Lambda$930/320860012@7d3aaf87, 0 ) @ res42.map(_.map(_.join)) res43: IO[List[IO[Int]]] = Map( Bind(Async(cats.effect.internals.IOStart$$$Lambda$2681/256186736@2faeea2), cats.FlatMap$$Lambda$2914/1434934951@60e127c1), scala.Function1$$Lambda$36/152134087@685766df, 1 ) @ res43.map(_.sequence).flatten.unsafeRunSync scala-execution-context-global-2441At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2439At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2439At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2657At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2439At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2657At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2439At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2660At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2657At time = 2018-05-28T16:15:58.495Z scala-execution-context-global-2438At time = 2018-05-28T16:15:58.496Z scala-execution-context-global-2441At time = 2018-05-28T16:15:58.496Z res44: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)