jkbbwr
04/13/2017, 6:49 PMkevinherron
04/14/2017, 2:54 PMnimtiazm
04/15/2017, 8:57 AMelizarov
04/19/2017, 10:03 AMpromise.then {
it.doSomething()
}
with
launch {
promise.await().doSomething()
}
This is quite a liberal example hand-crafted so that both direct usage of promise and coroutines somewhat match in readability. Coroutine benefits accrue with complex processing pipelines (do something async, then something else async, handle exceptions of multiple async actions in one place, etc).louiscad
04/19/2017, 1:40 PMAny
instead of default implicit Any?
louiscad
04/19/2017, 1:42 PMinvokeOnCompletion { ... }
. It runs regardless of the fact that the coroutine was cancelled or just completed successfully, right?Paul Woitaschek
04/19/2017, 2:03 PMelizarov
04/19/2017, 2:53 PMdg3feiko
04/19/2017, 3:35 PMkirillrakhman
04/20/2017, 7:56 AMumar
04/21/2017, 8:34 PMthomasnield
04/24/2017, 1:28 PMkirillrakhman
04/26/2017, 7:53 AMgroostav
04/26/2017, 8:08 AMdeviant
04/28/2017, 2:25 PMsuspend val text = readFromFile()
pniederw
05/03/2017, 11:21 PMpniederw
05/03/2017, 11:23 PMelizarov
05/04/2017, 6:58 AMsuspend fun
(this is covered in the spec quite well) in anticipation of suspension, even if that invocation will decide not to suspend. So here is the full table of differences:
spill on suspend restore on resume
Quasar LAZY EAGER
Kotlin EAGER LAZY
You can interpret it in this way: Quasar is optimised for the code that rarely suspends, while Kotlin coroutines are optimised for the code that often suspends. This properly of Kotlin coroutines is not an accident, since they were originally optimised for an efficient implementation of generateSequence/yield
pair that should work almost as fast as a manual implementation of the Sequence
. However, we have a lot of room to tweak those performance trade-offs in future updates (even without breaking compatibility) as we get more data on how coroutines get actually used in the wild.orangy
05/04/2017, 10:03 AMtinycedar
05/05/2017, 6:18 AMwinteryoung
05/06/2017, 5:06 AMalband
05/09/2017, 8:47 AMsuspend
not to be applicable on read-only (val
) property ?elizarov
05/12/2017, 2:31 PMkirillrakhman
05/15/2017, 5:19 PMfun main(args: Array<String>) = runBlocking(CommonPool) {
val result = service.someCall().awaitResponse()
println(result)
}
gildor
05/15/2017, 7:17 PMgildor
05/15/2017, 7:50 PMjw
05/15/2017, 8:05 PMCall
type is unchanged from the .0 release to the current minor release with regard to what it takes to adaptkirillrakhman
05/17/2017, 1:29 PMval Cached = Executors.newCachedThreadPool().asCoroutineDispatcher()
class Foo {
fun doBlocking(): Any {
Thread.sleep(1000)
return Any()
}
}
suspend fun Foo.doAsync(): Any {
return async(Cached) {
doBlocking()
}.await()
}
elizarov
05/18/2017, 9:28 PMkotlinx-coroutines-jdk8
you can write something like:
val coercedResult = future {
try { result.await() }
catch(ex: Throwable) {
Thread.handleUncaughtException(ex)
emptyList()
}
}
kirillrakhman
05/19/2017, 11:27 AMkotlin.coroutines=enable
in the gradle.properties file not supported anymore?kirillrakhman
05/19/2017, 11:27 AMkotlin.coroutines=enable
in the gradle.properties file not supported anymore?elizarov
05/19/2017, 12:55 PMkirillrakhman
05/19/2017, 12:57 PM