kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Impossible to attach coroutine context to CompletableJob

Open dovchinnikov opened this issue 3 years ago • 3 comments
trafficstars

I've managed to dump the full parent-child tree via internal APIs (https://github.com/Kotlin/kotlinx.coroutines/issues/3427), and I've discovered, that the coroutine name is not attached to the Job created by CoroutineScope. The name is only copied to child coroutines as is.

val cs = CoroutineScope(CoroutineName("MyComponent"))

Another title of this issue: "CoroutineScope is not a coroutine like launch/async".

dovchinnikov avatar Aug 25 '22 11:08 dovchinnikov

Currently, we have to use the following approach:

https://github.com/JetBrains/intellij-community/blob/8bce81b67d20a1fc0f538cc0d3c1c04b15b61790/platform/util/src/com/intellij/util/coroutineScope.kt#L25

dovchinnikov avatar Jan 20 '23 18:01 dovchinnikov

Currently, we have to use the following approach:

https://github.com/JetBrains/intellij-community/blob/8bce81b67d20a1fc0f538cc0d3c1c04b15b61790/platform/util/src/com/intellij/util/coroutineScope.kt#L25

Excuse me, how to achieve it? My code is as follows: image

But the result is not satisfactory。 PS: Run in Android Studio

DQSecret avatar Feb 10 '23 08:02 DQSecret

New approach: https://github.com/JetBrains/intellij-community/blob/819b1d9cd68a4638f3fa74ae445253d7e768108b/platform/util/coroutines/src/com/intellij/platform/util/coroutines/coroutineScope.kt#L41C15-L41C25

dovchinnikov avatar Nov 28 '23 14:11 dovchinnikov