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

Add ability to create a child scope

Open dovchinnikov opened this issue 3 years ago • 1 comments

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()
  }
}

dovchinnikov avatar Aug 25 '22 10:08 dovchinnikov

See issue #2758 :)

circusmagnus avatar Sep 02 '22 19:09 circusmagnus

Closing as duplciate

qwwdfsad avatar May 05 '23 12:05 qwwdfsad