Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonadCancel#uncancelable disrepancies #562

Open
neko-kai opened this issue Jul 12, 2022 · 0 comments
Open

MonadCancel#uncancelable disrepancies #562

neko-kai opened this issue Jul 12, 2022 · 0 comments

Comments

@neko-kai
Copy link
Member

Given the description of behavior of Poll produced by MonadCancel#uncancelable in its scaladoc:

 /** ...
   * Masks can also be stacked or nested within each other. If multiple masks are active, all
   * masks must be undone so that cancelation can be observed. In order to completely unmask
   * within a multi-masked region the poll corresponding to each mask must be applied to the
   * effect, outermost-first.
   *
   * {{{
   *
   *   F.uncancelable { p1 =>
   *     F.uncancelable { p2 =>
   *       fa *> p2(p1(fb)) *> fc
   *     }
   *   }
   *
   * }}}
   *
   * The following operations are no-ops:
   *
   *   1. Polling in the wrong order
   *   1. Subsequent polls when applying the same poll more than once: `poll(poll(fa))` is
   *      equivalent to `poll(fa)`
   *   1. Applying a poll bound to one fiber within another fiber
   *
   * @param body
   *   A function which takes a [[Poll]] and returns the effect that we wish to make
   *   uncancelable.

ZIO.uninterruptibleMask as uncancelable does not satisfy this description:

  1. In the code example, with ZIO, applying p1(fb) alone is enough to restore full interruptibility. The sentence "In order to completely unmask within a multi-masked region the poll corresponding to each mask must be applied to the effect, outermost-first." is not satisfied.
  2. "Applying a poll bound to one fiber within another fiber is no-op" is not satisfied – restore functions produced by ZIO.uninterruptibleMask can migrate fibers and are not invalidated when used on another fiber.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant