marcinmoskala
10/18/2021, 11:46 AMcoroutineScope
, withContext
, withTimeout
and supervisorScope
have very similar behavior and this group should have a name. In some places they are referenced as "Scoping functions", but I understand this can be confused with "Scope functions". What are your feelings about that? I am considering naming them "Coroutine scope function" or "Coroutine scoping functions".Joffrey
10/18/2021, 11:51 AMcoroutineScope
and supervisorScope
create a scope to allow launching coroutines, and suspend until those child coroutines terminate. These 2 could be grouped. The 2 others don't provide a scope, so they have quite different usage patterns and I don't quite get the need for a name that would encompass them as well. withTimeout
is just a suspend function like any other, and I don't see it as related to withContext
marcinmoskala
10/18/2021, 3:38 PMcoroutineScope
, withContext(EmptyCoroutineContext)
and withTimeout(Long.MAX_VALUE)
. They all create scope.Joffrey
10/18/2021, 3:45 PMwithTimeout
and withContext
actually do provide a scope. That being said, they popped in such different contexts in my experience that I actually never had to consider these 4 as a group.
And in particular, I never used withTimeout
or withContext
to actually start coroutines - just to control the timeout of some suspending code, or change the context. Starting a coroutine with withContext
would be equivalent to just pass that context to the actual coroutine builder.julian
10/18/2021, 6:46 PMwithTimeout
created a new scope. But I'm glad to see confirmation that withContext
does create a new scope, rather than "just" modify context.marcinmoskala
10/18/2021, 7:15 PMjulian
10/18/2021, 7:49 PM