Is there some significant runtime overhead for Cor...
# coroutines
u
Is there some significant runtime overhead for CoroutineScope instance, i.e lets say having 30of them, vs 1 shared thats being injected?
t
I think it depends on what kind of Scope your using. is it a thread pool, or what?
e
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.