Skip to content

Instantly share code, notes, and snippets.

@TomasStanek
Created August 13, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomasStanek/f06b89d888e0aed2350375470367cbcd to your computer and use it in GitHub Desktop.
Save TomasStanek/f06b89d888e0aed2350375470367cbcd to your computer and use it in GitHub Desktop.
name := "scalaScratch"
scalaVersion := "2.12.6"
version := "0.1"
scalacOptions := Seq(
"-Ypartial-unification",
"-deprecation",
"-feature",
"-unchecked",
"-language:higherKinds",
"-Xlog-reflective-calls",
"-Yinfer-argument-types"
)
def catsVersion = "1.1.0"
def catsEffectVersion = "1.0.0-RC2"
// def catsEffectVersion = "1.0.0-RC2-93ac33d"
// def monixVersion = "3.0.0-RC1"
// def fs2Version = "0.10.1"
def fs2Version = "1.0.0-M1"
libraryDependencies ++= Seq(
// "io.monix" %% "monix" % monixVersion,
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-effect" % catsEffectVersion,
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-io" % fs2Version
)
package scratch
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import cats.effect.IO
object Main {
def timeoutLeak() {
val p = IO.pure(())
val to = IO.sleep(100.seconds)
// racing with r10 instead of to actually doesn't make thing worse
/*
val r1 = IO.race(to, to)
val r2 = IO.race(r1, r1)
val r3 = IO.race(r2, r2)
val r4 = IO.race(r3, r3)
val r5 = IO.race(r4, r4)
val r6 = IO.race(r5, r5)
val r7 = IO.race(r6, r6)
val r8 = IO.race(r7, r7)
val r9 = IO.race(r8, r8)
val r10 = IO.race(r9, r9)
*/
def loop(): IO[Unit] = {
IO.race(to, p)
.flatMap(_ => loop())
}
(
for {
fib1 <- loop().start
fib2 <- loop().start
fib3 <- loop().start
fib4 <- loop().start
_ <- fib1.join
_ <- fib2.join
_ <- fib3.join
_ <- fib4.join
} yield {
()
}
)
.unsafeRunSync
}
def main(args: Array[String]) {
timeoutLeak()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment