Skip to content

Document interactions of custom ContinuationInterceptor and prompt cancellation #2439

Open
@qwwdfsad

Description

@qwwdfsad

Currently, we can provide a prompt cancellation guarantee if and only if the underlying dispatcher is an instance of CoroutineDispatcher.

The reason is that prompt cancellation guarantee is cooperative -- it requires cooperation between dispatcher-agnostic CancellableContinuation and the underlying intercepted continuation (link to the cooperation point).

Without such cooperation, it's easy to break and observe atomic cancellation.

We should find a mechanism to either workaround it or warn users about this issue. At the very least we have to document this behaviour.

Note that this is not an ephemeral issue and it was discovered during debugging of Lincheck misbehaviour when using with prompt cancellation

Metadata

Metadata

Assignees

No one assigned

    Labels

    designdocsKDoc and API reference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions