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

Ability to specify a limited dispatcher name #4023

Open
dovchinnikov opened this issue Jan 25, 2024 · 2 comments
Open

Ability to specify a limited dispatcher name #4023

dovchinnikov opened this issue Jan 25, 2024 · 2 comments
Assignees

Comments

@dovchinnikov
Copy link
Contributor

Use case

We have specific dispatchers, and in coroutine dumps they all look like LimitedDispatcher@xxxxxxxx, and it's not immediately clear where the dispatcher comes from.

The Shape of the API

Make kotlinx.coroutines.CoroutineDispatcher.limitedParallelism accept debugName: String?.

Alternatively, make an extension function fun CoroutineDispatcher.namedDispatcher(debugName: String): CoroutineDispatcher which will return a dispatcher, which delegates to this and has its toString overridden. It can return this as is when debug is off.

Prior Art

kotlinx.coroutines.scheduling.LimitingDispatcher has name.

@vsalavatov
Copy link

I'm concerned that .namedDispatcher() can be misused to give a new alias to an existing dispatcher that is used somewhere else. It can potentially make this connection unobvious and, for example, hinder debugging of an issue with concurrency involved.
I think that giving a dispatcher a name should be inseparable from creating one. I believe this would be a safer approach.

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

3 participants