Tristan Hamilton
02/04/2021, 10:18 PMMarc Knaup
02/04/2021, 10:35 PMparentScope
is confusing. You’re passing the child, not the parent.Marc Knaup
02/04/2021, 10:39 PMcoroutineScopeWrapper
returns immediately because two two launch
are executed in the real parent scope of runBlocking
and thus the scope of async
doesn’t need to wait for them.Tristan Hamilton
02/04/2021, 10:39 PMasync
builder, that is the "parent" coroutine, and so from there im passing that downMarc Knaup
02/04/2021, 10:42 PMrunBlocking
is the topmost scope.
coroutineScope
is a child of runBlocking
(more or less).
async
is a child of coroutineScope
.
And the launch in your wrapper use the CoroutineScope
of runBlocking
so they’re direct children of it.Marc Knaup
02/04/2021, 10:42 PMlaunch
basically means this@runBlocking.launch
in your example.Marc Knaup
02/04/2021, 10:43 PMcancel()
doesn’t cancel. WTF 😄Tristan Hamilton
02/04/2021, 10:46 PMcoroutineScope
provides a different Job and that the launches were "tied" to it, but I guess they still have the same context which is runBlocking?
So to make this cancel the way I expect, would I need to define a new scope in coroutineScopeWrapper
instead?Marc Knaup
02/04/2021, 10:47 PMlaunch
is tied to it. But you don’t give the launch
invocation the CoroutineScope
of the async
.Marc Knaup
02/04/2021, 10:49 PMMarc Knaup
02/04/2021, 10:51 PMTristan Hamilton
02/04/2021, 10:52 PM