Skip to content

Cancellable or not #6

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

Closed
agcom opened this issue Feb 7, 2021 · 1 comment
Closed

Cancellable or not #6

agcom opened this issue Feb 7, 2021 · 1 comment
Assignees
Labels
improvement Alter for better

Comments

@agcom
Copy link
Owner

agcom commented Feb 7, 2021

Asynchronous channels provide no guarantee nor function to cancel calls. Should this behavior be reflected in coroutines (suspendCancellableCoroutine or cancellableCoroutine)?

@agcom agcom added the improvement Alter for better label Feb 7, 2021
@agcom
Copy link
Owner Author

agcom commented Feb 7, 2021

Suspending calls are not actually cancellable anyway. The caller should ignore results to mimic cancellation.

I guess the default should be cancellableCoroutine.

  • User can still ignore the call (accepting consequences) by wrapping it into a coroutine Job (async or launch do create a new job).
  • By closing the channel, all suspend calls will continue with an exception (that covers most use-cases).
  • I don't recall any compelling use-case for suspendCancellableCoroutine.

@agcom agcom self-assigned this Feb 7, 2021
@agcom agcom closed this as completed in f7e7bbc Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Alter for better
Projects
None yet
Development

No branches or pull requests

1 participant