Skip to content

An API for not populating the exception stacktraces for coroutines that are likely to get cancelled #4535

@dkhalanskyjb

Description

@dkhalanskyjb

Some coroutines are very likely to get cancelled a short time after they are launched, making the CancellationException stacktrace calculation into a large portion of the runtime.

Examples:

This calls for an API that allows not populating the stacktraces but instead using a CancellationException object created in advance.

Options:

  1. Cancel-site: cancel already can accept custom CancellationException variants, and withTimeout* could also be parameterized to allow this.
  2. Throw-site: suspendCancellableContinuation could react to a special CoroutineContextElement specifying that the cancellation exception of the suspended coroutine itself does not need to be instantiated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions