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

Consider deprecation cycle for CoroutineDispatcher.invoke #4199

Open
JakeWharton opened this issue Jul 29, 2024 · 6 comments
Open

Consider deprecation cycle for CoroutineDispatcher.invoke #4199

JakeWharton opened this issue Jul 29, 2024 · 6 comments
Labels

Comments

@JakeWharton
Copy link
Contributor

CoroutineDispatcher.invoke, a function used as such:

Dispatchers.IO {
  stuff
}

is a shorter version of withContext that only works with dispatchers.

Does this function need to exist? It seems to predate structured concurrency and is so terse that it offers no indication as to its underlying behavior. Does it launch a new coroutine? Does it move the current coroutine? Does the supplied block honor structured concurrency?

I personally have a hard time finding a reason for this function to continue to exist.

@CLOVIS-AI
Copy link
Contributor

For context, it was originally added in #428 as an experiment. As far as I know, it is very rarely used (if at all) in the ecosystem.

@dkhalanskyjb
Copy link
Collaborator

Very few usages found:
https://grep.app/search?q=.IO%20%7B&case=true&filter[lang][0]=Kotlin
https://grep.app/search?q=Dispatchers.Default%20%7B&case=true&filter[lang][0]=Kotlin
https://grep.app/search?q=Dispatchers.Main%20%7B&case=true&words=true&filter[lang][0]=Kotlin

I personally find this to be non-idiomatic modern Kotlin. Thing { } looks to me like a builder of some sort. So, I'm for this.

@qwwdfsad
Copy link
Collaborator

qwwdfsad commented Aug 1, 2024

We can try and proceed with it in RC2 along with other deprecations

@dkhalanskyjb
Copy link
Collaborator

I'm not sure what I expected, but the deprecation doesn't look pretty in the IDE!
Screenshot_20240801_134245
Given how rare this is, I don't think this should stop us, though.

@dkhalanskyjb
Copy link
Collaborator

2024-08-01-135455_1613x586_escrotum.webm

dkhalanskyjb added a commit that referenced this issue Aug 1, 2024
@JakeWharton
Copy link
Contributor Author

Finding some good IntelliJ bugs/feature requests at least!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants