I want to run multiple async tasks that doesn't af...
# coroutines
j
I want to run multiple async tasks that doesn't affect each other neither their parent. Eg. something like:
Copy code
(0..4)
	.map { async { .... } }
	.forEach {
		try  { 
			it.await()...process
		} catch() {}
	}
Which coroutine scope builder I should use? Using
coroutineScope {}
or
supervisorScope {}
would cancel the parent or siblings respectively.
d
supervisorScope doesn't cancel siblings
n
If you want the asyncs to be cancelled when the parent is cancelled, use
supervisorScope
. If you want the asyncs to be completely isolated from the parent, use
GlobalScope
.
j
well, ideally I want them to cancelled if parent is cancelled, but not to cancel parent if they fail.