marcinmoskala
01/29/2018, 5:20 PMJob
complition, but what are the dangers of lack of join
?jw
01/29/2018, 6:01 PMjw
01/29/2018, 6:02 PMelizarov
01/29/2018, 6:06 PMcancel
just signals “start shutting down please”, and if you don’t join
your code might be doing stuff concurrently with another coroutine that is still shutting down.elizarov
01/29/2018, 6:20 PMkotlinx.coroutines
version 0.22.1
is released with a number of bug fixes: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/0.22.1r4zzz4k
01/29/2018, 6:30 PMrunBlocking
handy!groostav
01/30/2018, 12:56 AMCoroutineExceptionHandler
executed. can one of you guys take a peek and tell me what im missing?groostav
01/30/2018, 12:56 AMjw
01/30/2018, 5:02 AMjw
01/30/2018, 5:05 AMjw
01/30/2018, 5:05 AMelizarov
01/30/2018, 6:58 AMselect
are supposed to be general, though API for that (registerSelectClauseX
methods and SelectInstance
interface) is still somewhat unstable. It needs design review and maybe some simplification.btw
01/30/2018, 7:49 AMbtw
01/30/2018, 7:49 AMelizarov
01/30/2018, 11:02 AMdstarcev
01/30/2018, 11:26 AMinterface
, should I mark functions with suspend
or should I return Deferred<T>
?dstarcev
01/30/2018, 11:27 AMinterface SmsService {
suspend fun send(phone: String, message: String)
}
interface SmsService {
fun send(phone: String, message: String): Deferred<Nothing>
}
dstarcev
01/30/2018, 11:27 AMlouiscad
01/30/2018, 11:28 AMlouiscad
01/30/2018, 11:29 AMDeferred
provides and just have the function to suspend
is enough, then use suspend
, it will save a Deferred
implementation instance to be createdelizarov
01/30/2018, 11:30 AMsuspend
, unless you have some interop requirements that mandate that you use futures.dstarcev
01/30/2018, 11:31 AMdstarcev
01/30/2018, 12:40 PMsuspend
when design a non-blocking service?dstarcev
01/30/2018, 12:41 PMdstarcev
01/30/2018, 12:42 PMdstarcev
01/30/2018, 12:42 PMdstarcev
01/30/2018, 12:43 PMsuspend
and the other not, it will be kind of leaky abstractionelizarov
01/30/2018, 12:46 PMsuspend
when you expect their implementation to be non-blocking to the invoker thread (aka “asynchronous”). So, if I read your API and see interface Foo { fun doSomethingNetworkRelated() }
, then I immediately see that doSomethingNetworkRelated
is going to block my thread while it does its network stuff. However, if I see interface Foo { suspend fun doSomethingNetworkRelated() }
then I assume that implementation is non-blocking and can be safely used, for example, from my UI thread or from other precious event-loop.elizarov
01/30/2018, 12:47 PMelizarov
01/30/2018, 12:49 PMsuspend
function in a non-blocking way, then your code is going to be beautiful and scalable whether you are writing front-end or back-end code.