kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Add ability to create a child scope
Similar to:
launch { // parent
launch { // child
...
}
}
Given a parent scope, I'd like to be able to attach a child to it. This child scope has to follow coroutine hierarchy w.r.t. cancellation propagation and parent completion.
class MyComponent(parent: CoroutineScope) {
private val cs = parent.childScope(CoroutineName("MyComponent"))
// launch coroutines in cs
fun shutdown() {
cs.cancel()
}
}
See issue #2758 :)
Closing as duplciate