7mind / izumi

Productivity-oriented collection of lightweight fancy stuff for Scala toolchain

Home Page:https://izumi.7mind.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make `produce` itself interruptible to work with ZIO interruption inheritance

neko-kai opened this issue · comments

commented

After #1138 Lifecycle encoding itself supports interruptibility, but since the entirety of Injector#produce happens in an uninterruptible region, this causes problems with ZIO's odd interruption inheritance (gitter thread)

It seems like this can't be solved by just wrapping all ZIO's in .interruptible, because ZIO effects can come not just from ZManaged, but from Lifecycle and Resource too.

Instead, produce can be made interruptible, with individual resource acquiries being uninterruptible, as long as we setup a finalizer for contents of ProvisionMutable and as long as the region between Lifecycle being acquired and its finalizer being inserted into ProvisionMutable is uninterruptible, it would be safe to for the rest of produce to be interruptible.