-
Notifications
You must be signed in to change notification settings - Fork 522
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
Improve MonadCancel
scaladoc
#3994
Comments
I rewrote the test to be slightly more explicit: "foobar" in real {
IO(new AtomicInteger) flatMap { ctr =>
val test = IO.deferred[Unit] flatMap { latch =>
val t = IO uncancelable { poll =>
latch.complete(()).uncancelable *> poll {
IO.async_[Unit] { cb =>
ctr.getAndIncrement()
cb(Right(()))
}
}
}
t.start flatMap { fib =>
latch.get *> fib.cancel *> fib.joinWithUnit
}
}
val N = 100
test.replicateA_(N) flatMap { _ =>
IO(ctr.get()) flatMap { count =>
IO(count mustEqual N)
}
}
}
} I think this also reveals where the problem is: in the partial expression So what does this have to do with us here? Well, So I think this isn't a bug. |
I think the F.uncancelable(poll => foo(poll)).flatMap(f)
Then it talks about Resource.eval(IO.unit).allocated.flatMap { x => IO.delay(...) } And we're getting cancelled after Besides all this, in |
Yeah I think this would be worth updating. The scaladoc isn't inaccurate (it says the
Yeah this is a common pattern. In general, the way to think about it is that you shouldn't assume anything about the trailing |
Yeah, okay, I'm reopening and making this a docs issue.
No gaps at the end. There is a gap |
This test fails:
I believe this shows that
IO.async_
is cancelable: waiting onlatch
ensures, that the fiber is not cancelled before even starting; and the boundary afteruncancelable
(i.e., right beforeasync_
) is non-cancelable. While it was removed from theasync_
scaladoc that it is uncancelable (by #3091), I don't think this is intentional. I think it's intended to be uncancelable.A similar case is observable if
async
returnsNone
(i.e., no finalizer). And also forasyncCheckAttempt
, and even if it returnsRight(...)
.I'm not sure about the impact of this, as they seem to be cancelled before registration (i.e., between
IOCont
andbody
). But this seems like a bug.The text was updated successfully, but these errors were encountered: