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

[guava] If ListenableFuture is cancelled, it should cancel entangled coroutine before executing the listeners #2409

Open
vadimsemenov opened this issue Nov 25, 2020 · 0 comments

Comments

@vadimsemenov
Copy link
Contributor

This is related to ListenableFutures returned from Deferred.asListenableFuture and CoroutineScope.future.

Currently we override AbstractFuture.cancel and call super.cancel() before cancelling the coroutine.
This means that if the future has a slow listener, it can delay cancellation of the coroutine.

AbsractFuture explicitly recommends afterDone for this use case. We can use it when the API is finalised (at this moment afterDone is annotated with @Beta).

However, one disadvantage of afterDone, is that we'll have to unconditionally check if the future isCancelled(), which will cost us a volatile read even in case when the future is completed successfully.

See #2222 for more info, it added two @Ignored tests related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants