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

dave08

12/06/2017, 3:20 AM
@elizarov But in the docs, it says that
Unconfined
is the equivalent of not using a scheduler in Rx, and it's very common, say in android, to want to run mainly on the current thread (with fan out/in, that SHOULD block the current thread only for the result), like in an IntentService that already has a working thread (that shouldn't stop until all tasks are finished, otherwise there could be leaks...)... in that case, is it better to use
runBlocking
or
launch(Unconfined)
, or is there no difference...? There's no clear rules about this in the docs, only 'hints' that seem a bit contradictory at times... Also, when is there a need for the top level
yield
function I mentioned before? Does it have to do with certain contexts being CorotineStart.dispatched by default or not?
e

elizarov

12/06/2017, 8:09 AM
It is equivalent to not using scheduler and caries all the equivalent risks. As long as you doing some fast computations from there are are not touching any shared mutable state you are usually fine. When in doubt, just specify the context explicitly
3 Views