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

Deprecate ExecutorCoroutineDispatcher.Key for removal #4333

Open
qwwdfsad opened this issue Jan 16, 2025 · 0 comments
Open

Deprecate ExecutorCoroutineDispatcher.Key for removal #4333

qwwdfsad opened this issue Jan 16, 2025 · 0 comments

Comments

@qwwdfsad
Copy link
Collaborator

Originally, it was added as a proof-of-concept of "disjoint polymorphism" in coroutine context elements: https://youtrack.jetbrains.com/issue/KT-36118

In short, for the polymorphic type hierarchy (e.g. ContinuationInterceptor -> CoroutineDispatcher -> ExecutorCoroutineDispatcher) it enables use of the corresponding context keys with the preservation of type properties -- ctx[ContinuationInterceptor] works for all types, ctx[CoroutineDispatcher] works for CD and so on).

The problem with this API (both in the stdlib and coroutines) is that it is error-prone (i.e. the correct implementation is neither ergonomic nor easy to get from the first try, with no clear indication of a bug), can be much more safely and meaningfully, replaced with a corresponding extension (i.e. ctx.job and, potentially, ctx.dispatcher) and leaks implementation details (for example, a dispatcher might be reasonably used with asExectutor() and not be available via ExecutorCoroutineDispatcher).

The API (that is experimental, with ERROR) should be deprecated in the Kotlin and its usages in coroutines

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

1 participant