Hi guys, this is a question of concept. Under whic...
# coroutines
j
Hi guys, this is a question of concept. Under which circumstances would it be beneficial to
launch
a single coroutine in a
runBlocking
scope? Example
Copy code
fun foo() {
	runBlocking {
		launch {
			// some suspend functions
		}
	}
}
Instead of
Copy code
fun foo() {
	runBlocking {
		// some suspend functions
	}
}
s
Just one launch, not much benefit. But if you do multiple launch-es, you can do stuff in parallel and have runBlocking return when they are all done.
j
That's what I thought. Is there any benefit for a single
launch
though?
a
There is no benefit at all for a single
launch
.
e
No benefit. A single
launch
inside
runBlocking
should be totally transparent.
a
The man himself hath spoken
😂 3
s
To be sure; a
runBlocking
with j*ust* a single
launch
is totally transparent, but it could still have one
launch
and some other code, which then would happen in parallel. 🙂
Copy code
runBlocking {
    launch { .... }
    here() 
    is()
    someOtherCode()
}