pniederw
01/20/2017, 11:32 PMelizarov
01/27/2017, 12:12 PMkotlinx-coroutines-rx
does not support cancellation yet.hackerham
01/27/2017, 12:12 PMorangy
hackerham
01/28/2017, 2:02 PMDeactivated User
01/29/2017, 2:29 PMdmitry.petrov
01/31/2017, 9:37 AMPaul Woitaschek
01/31/2017, 10:04 AMorangy
class Platform(left: Float, right: Float, vertical : Float, speed : Float) : Actor() {
…
fun suspend behaviour() {
while (true) {
for (x in left..right step speed) {
moveTo(x, vertical) // frame-synced suspend function
}
for (x in right downTo left step speed) {
moveTo(x, vertical)
}
}
}
rrader
02/02/2017, 2:48 PMelizarov
02/07/2017, 7:42 AMkotlinx.coroutines
version 0.7-beta
is published. It includes production-quality mostly lock-free implementation of Go-style channels that enable coroutines to safely share streams of arbitrary elements or messages without actually sharing any mutable state (e.g. share data by communicating). More details here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#channelsgroostav
02/07/2017, 6:56 PMsend
and recieve
are too conventional, its time we got some scala up in this and named them !
and <-
, or something similar. /sarcasmelizarov
02/08/2017, 7:51 PMasync
in C#/JS/Dart uses implicit context (in C# that depends on the thread you are calling from, and in JS/Dart that's the event loop context), while in Kotlin we decided to make the context explicit.pniederw
02/09/2017, 3:44 AMdefer
to async
, will you also rename future
back to async
?voddan
02/09/2017, 4:54 AMDeferred
to Asynced
, we can avoid the mismatch in namesvoddan
02/09/2017, 6:50 AMrunBlocking {}
, etc. Can't we rename that into blocking {}
?cedric
02/09/2017, 7:02 AMblockBlock
, a verb and a noun. Problem solved.antonkeks
02/09/2017, 8:29 PMgildor
02/09/2017, 11:23 PMrrader
02/10/2017, 8:58 AMasync
should return Coroutine
classjulienviet
02/10/2017, 3:45 PMelizarov
02/13/2017, 8:31 PMgaetan
02/18/2017, 12:39 AMPaul Woitaschek
02/20/2017, 8:31 PMelizarov
02/20/2017, 9:41 PMsuspendCoroutine
is too low level. It takes large amount of code just to reliably pass a signal from one coroutine to the other. It is like writing your own blocking queue using volatile variables, atomics and LockSupport.Paul Woitaschek
02/21/2017, 12:38 PMPaul Woitaschek
02/21/2017, 10:29 PMmkobit
02/22/2017, 12:56 AMkotlinx-coroutines-jdk8
library to support helpers for Channel
that adapt it to a Stream
?voddan
02/22/2017, 4:38 PMThis is the fastest solution for this particular problem
are not very reassuringuli
02/23/2017, 9:09 AMval massive = 1_000_000
private suspend fun aMassiveRun(context: CoroutineContext = CommonPool, action: suspend () -> Unit) {
val jobs = List(massive) {
launch(context) {
action()
}
}
jobs.forEach { it.join() }
}
private object ThreadConfinement1: Callable<Int> {
val counterContext = newSingleThreadContext("CounterContext")
override fun call(): Int {
var counter = 0
runBlocking<Unit> {
aMassiveRun(counterContext) {
counter++
}
}
return counter
}
}
private object ThreadConfinement2: Callable<Int> {
val counterContext = newSingleThreadContext("CounterContext")
override fun call(): Int {
var counter = 0
runBlocking<Unit> {
aMassiveRun {
run(counterContext) {
counter++
}
}
}
return counter
}
}
I time both callables 5 times to warm up hotspot and only take the last measurement.
Both tests run all incrementation on a single thread but ThreadConfinement2 does the scheduling of the actual work in form the CommonPool.