https://kotlinlang.org logo
#coroutines
Title
# coroutines
g

groostav

07/30/2019, 3:03 AM
is it a bug that
runBlocking(JavaFx) { runBlocking(JavaFx) { }}
causes deadlock but
runBlocking(JavaFx) { runBlocking { }}
does not?
g

gildor

07/30/2019, 3:07 AM
I would create an issue on Kotlinx.coroutines issue tracker
a

Adam Powell

07/30/2019, 3:11 AM
in the second example you are creating a local event loop within a single event being processed on the
JavaFx
dispatcher and blocking the
JavaFx
thread until that new event loop exits, but in the first example the inner
runBlocking(JavaFx)
says, "block the current thread I am on until the coroutine I would like to run on the JavaFx dispatcher completes", but you're already on the JavaFx dispatcher and blocking it, so the thing you're waiting for can't start.
it would kind of violate the contract of
runBlocking
if there were some magic in there to turn it into a trampoline in cases like this
u

uli

07/30/2019, 4:43 AM
e

elizarov

07/30/2019, 6:55 AM
File an issue if you have a use-case where you want the other one not to block.
16 Views