Paul Woitaschek
02/28/2018, 12:52 PMrxXYZ
methods?louiscad
02/28/2018, 1:36 PMReceiveChannel
/ actor that cancels the work done for a value if a new one is received? My goal is to perform a computation for the latest received value and drop any in progress work.voddan
02/28/2018, 3:29 PMlaunch(CommonPool.copy(parent = job)) {}
Starting to think that the +
was too cryptic to begin withwithoutclass
02/28/2018, 3:54 PMdelay
if I want to make sure my routine is cooperative, but I don't need to actually delay anything? Is 1ms too little time? Curious if there is some best practice around that yetjkbbwr
03/01/2018, 1:21 PMtrathschlag
03/01/2018, 2:52 PMReceiveChannel
which lazily produces work and I want to schedule these on CommonPool
. I can't just take every task from the source, because there are infinite. What's a good way to assure that for example always 1000 tasks are currently in my thread pool?dave08
03/02/2018, 10:31 AMsuspend
function in stdlib in 1.2.30? The release notes have an example that's not too clear to me what the point is...?
suspend { val result = deferredResult.await() renderResult() }.startCoroutine(completion)
louiscad
03/03/2018, 10:12 AMlaunch
, withContext
, async
, the suspend
modifier, which CoroutineContext to pick, what a Job
is, how to wrap a callback with suspendCoroutine
, how to handle errors, how to handle lifecycles of Android components. I'll also talk about some good libraries made on coroutines. Namely, @gildor and @jw ones for Retrofit. I'll also talk about channels and how it can be used for actors and to wrap true callback hells.
Since this is my first public article, I'm unsure about the results, but I'm determined.
I can share the draft to anyone willing to give feedback or willing to help in any other way.
The current title of the draft article is kotlinx.coroutines intro for Android Devs. Please tell me if you dislike it or if you think you have a better one.kasper.kondzielski
03/03/2018, 12:26 PMisActive
predicate returns false
but I don't know how to prevent itdeviant
03/04/2018, 11:57 AMkotlinx-coroutines-core-js
on npm?acando86
03/04/2018, 7:43 PMvoddan
03/05/2018, 12:41 PMsuspend
just in case?deviant
03/05/2018, 7:44 PMkotlinx-coroutines-core-js
doesn't work with create-react-kotlin-app
? i'm doing npm i kotlinx-coroutines-core --save
and still can't use launch/async etc. or should i import these functions with @JsModule?Paul Woitaschek
03/06/2018, 4:20 PMdave08
03/06/2018, 4:51 PMFutureTask
can receive a callback when it's finished, so you wouldn't have to block an extra thread to wait for the result... and it implements Future from api level 1...jw
03/06/2018, 4:54 PMjw
03/06/2018, 4:56 PMkotlinc
suffer in it on our behalfpakoito
03/06/2018, 8:25 PMjava.lang.IllegalStateException: Already resumedSo, `CoroutineContext`s are not reusable
elizarov
03/07/2018, 1:14 PMchannel.consumeEach { …. }
. The rest of the code will execute only when the channel is closeddeviant
03/07/2018, 2:30 PMpublic fun <E, R> ReceiveChannel<E>.flatMap(context: CoroutineContext = Unconfined, transform: suspend (E) -> ReceiveChannel<R>): ReceiveChannel<R>
is there any chance we will see overloaded flatmap in the lib with such param signature transform: (E) -> Iterable<R>
?dai
03/08/2018, 9:58 AMlouiscad
03/09/2018, 8:22 AMlaunch
and any other function whose lambda is a suspend
one)? This could be a play sign with the curve, similar to the arrow with the curve we have for suspension points. This would help knowing where suspend calls are allowed in current code, helping to see potentially unneeded coroutines launchesPaul Woitaschek
03/09/2018, 9:40 AMivanmorgillo
03/09/2018, 10:55 AMpakoito
03/09/2018, 11:04 AMstepango
03/11/2018, 11:20 AMstepango
03/11/2018, 3:47 PMfun main(args: Array<String>) {
launch(EmptyCoroutineContext) {
withContext(EmptyCoroutineContext) {
CompletableFuture.runAsync {
print("Hello")
}.await()
}
}
}
suspend fun <T> CompletableFuture<T>.await() = suspendCoroutine<T> { cont ->
cont.resume(join())
}
Hello
would never be printed in this casebj0
03/11/2018, 3:53 PMlaunch
and withContext
?stepango
03/11/2018, 3:56 PMfun main(args: Array<String>) {
val context = newSingleThreadContext("test")
launch(context) {
withContext(context) {
CompletableFuture.runAsync {
print("Hello")
}.await()
}
}
}
suspend fun <T> CompletableFuture<T>.await() = suspendCoroutine<T> { cont ->
cont.resume(join())
}
Not working😮oshai
03/12/2018, 9:58 AMoshai
03/12/2018, 9:58 AMJonathan
03/12/2018, 10:06 AM// take care of thread safety of the queue
val messages: Queue
// Create an actor design to receive "wake-up" message (Unit can be used as an element type)
// Conflated buffer is usefull to not buffer "wake-up" messages if the process is longuer than the time between two wake-ups
val actor = actor<Unit>(capacity = Channel.CONFLATED) {
consumeEach {
// process pending messages
}
}
init {
launch {
while(isActive) {
// wait 2 seconds
delay(2, TimeUnit.SECONDS)
// awake the actor
actor.send(Unit)
}
}
}
oshai
03/12/2018, 11:17 AM