06/16/2021, 10:36 AM
Is there some significant runtime overhead for CoroutineScope instance, i.e lets say having 30of them, vs 1 shared thats being injected?


06/16/2021, 11:13 PM
I think it depends on what kind of Scope your using. is it a thread pool, or what?


06/17/2021, 6:05 AM
I think I've seen a comment some time ago that said that a coroutine scope is just as cheap as any other object. So what's the price of 30 objects vs. 1 to you? • More objects cost more memory. • More objects aren't easier to handle or manage, but less not necessarily either. • What coroutine pattern are you using that it's a good idea to have 30 scopes? Are there really 30 contexts that use coroutines separate from each other? If you consider a coroutine scope a box: why do you need 30 separate boxes vs. just one? • Who will cancel the scope(s)? What's their lifecycle? To preserve structured concurrency, consider a coroutine scope a resource.