-
Notifications
You must be signed in to change notification settings - Fork 560
Closed
Labels
Description
As seen in zio/zio#267
We have this law:
def acquireIsNotCancelable[A](a1: A, a2: A) = {
val lh =
for {
mVar <- MVar[F].of(a1)
latch <- Deferred.uncancelable[F, Unit]
task = F.bracket(latch.complete(()) *> mVar.put(a2))(_ => F.never[A])(_ => F.unit)
fiber <- F.start(task)
_ <- latch.get
_ <- fiber.cancel
_ <- contextShift.shift
_ <- mVar.take
out <- mVar.take
} yield out
lh <-> F.pure(a2)
}This law introduces the assumption that fiber.cancel doesn't block. In cats.effect.IO's implementation there aren't at that point any finalizers registered so cats.effect.IO doesn't block on anything. But ZIO blocks for the completion of that fiber.
Which means that we need a fix that forks the cancel operation. E.g. we could use F.start(fiber.cancel) instead. Maybe even with an extra contextShift.shift just to be sure that it is indeed concurrent.
Published hash version with the fix for testing purposes:
1.0.0-1182d8c