withoutclass
12/05/2018, 6:56 PMcoroutineScope{}
style of method2
, sending is always suspended waiting on a receiver, but method1
does not get suspended(blocked).
As far as I can tell, both method 1 and method2 would launch using the same dispatcher (Dispatchers.IO), and that I'm not doing anything "wrong" per se, but clearly I am given I would expect method1
to not get stuck.CoroutineScope(coroutineContext)
in method2
, the code does not block execution. If I use GlobalScope.launch(coroutineContext)
, the code does not block execution.CoroutineScope(coroutineContext).launch
, given it uses parent context and dispatcher without actually blocking the execution of the function launching ituli
12/06/2018, 11:08 AMsend
to complete. Only then will method2 return the channel
.
Now send
will not complete until there is a recever...withoutclass
12/06/2018, 3:08 PMmethod
calls launch child coroutines using coroutineScope
or 2. Providing the channel to the method
call instead of having the method
return a new channelmethod2
suspendingmethod1
and method2
should just be producers from a design perspective?