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

Proposal: Add await for play-services integration for Task constructed with CancellationToken #2527

Closed
alexvanyo opened this issue Feb 5, 2021 · 0 comments

Comments

@alexvanyo
Copy link
Contributor

The current play-services integration provides Task.await that allows waiting for the result of an already created Task. This function supports cancellation, but not in both directions: If await is cancelled, then the underlying Task is not cancelled.

Some methods of creating Tasks don't support cancellation in this manner, but some do by creating the task with a CancellationToken. For an example: https://developers.google.com/places/android-sdk/reference/com/google/android/libraries/places/api/net/FindAutocompletePredictionsRequest.Builder#setCancellationToken(com.google.android.gms.tasks.CancellationToken)

My proposal is to add another await method, that operates on a lambda that constructs a Task given a CancellationToken.

pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
…Kotlin#2786)

* Support bi-directional cancellation for Task.asDeferred and Task.await via passed in CancellationTokenSource

Fixes Kotlin#2527

Co-authored-by: Alex Vanyo <vanyoalex@gmail.com>
Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
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