Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ object CatsEffectIssue380Suite extends SimpleTestSuite {
}
}

test("Semaphore does not block on release — typelevel/cats-effect#380") {
val service = Executors.newSingleThreadScheduledExecutor()
implicit val ec = ExecutionContext.global
implicit val cs = IO.contextShift(ec)
implicit val timer = IO.timer(ec, service)

try {
for (_ <- 0 until 10) {
val cancelLoop = Atomic(false)
val unit = IO {
if (cancelLoop.get()) throw new CancellationException
}

try {
val task = for {
mv <- Semaphore[IO](0)
_ <- (mv.acquire *> unit.foreverM).start
_ <- timer.sleep(100.millis)
_ <- mv.release
} yield ()

val dt = 10.seconds
assert(task.unsafeRunTimed(dt).nonEmpty, s"timed-out after $dt")
} finally {
cancelLoop := true
}
}
} finally {
service.shutdown()
}
}
// test("Semaphore does not block on release — typelevel/cats-effect#380") {
// val service = Executors.newSingleThreadScheduledExecutor()
// implicit val ec = ExecutionContext.global
// implicit val cs = IO.contextShift(ec)
// implicit val timer = IO.timer(ec, service)
//
// try {
// for (_ <- 0 until 10) {
// val cancelLoop = Atomic(false)
// val unit = IO {
// if (cancelLoop.get()) throw new CancellationException
// }
//
// try {
// val task = for {
// mv <- Semaphore[IO](0)
// _ <- (mv.acquire *> unit.foreverM).start
// _ <- timer.sleep(100.millis)
// _ <- mv.release
// } yield ()
//
// val dt = 10.seconds
// assert(task.unsafeRunTimed(dt).nonEmpty, s"timed-out after $dt")
// } finally {
// cancelLoop := true
// }
// }
// } finally {
// service.shutdown()
// }
// }
}