snrostov
10/24/2017, 11:01 AMpakoito
10/25/2017, 4:47 PMelizarov
10/26/2017, 8:29 AMinvokeOnCompletion
is mostly designed for internal machinery. Franky, I think it should be somehow “hidden” from API to discourage its use from a general-purpose application code, but I don’t know what would be best way to do it. You should define then
to get this “chained” style of programming like this:
fun <T, U> Deferred<T>.then(next: suspend (T) -> U): Deferred<U> = async { next(await()) }
We might include it in the future updates of kotlinx.coroutines
for convenience.Olekss
10/26/2017, 11:04 AMLuis
10/26/2017, 11:06 PMval outerJob = launch(CommonPool) {
val inner1 = launch(coroutineContext) { /* blah */ }
val inner2 = launch(coroutineContext) { /* blah */ }
// do more stuff
select<Unit> {
// These lines will actually throw a CancellationException if either of the inner jobs are completed exceptionally!!!
inner1.onJoin { val reason = inner1.getCompletionException(); /* blah */ }
inner2.onJoin { val reason = inner2.getCompletionException(); /* blah */ }
}
}
// Here I can call `outerJob.cancel()` to cancel everything
very awkward to writezarkopafilis
10/27/2017, 8:58 AMhydrakecat
10/27/2017, 12:04 PMFré Dumazy
10/27/2017, 12:16 PMlittlelightcz
10/27/2017, 4:55 PMelizarov
10/27/2017, 5:57 PMval ioPool = newThreadPoolContext(n, "ioPool")
Then you can wrap you IO operations into run(ioPool) { ... }
. This will be a suspending operations from the invoker stand-point, the actual execution happening in the thread pool you’ve defined, so that the invoker thread (UI thread, of some other event thread like netty or vert.x) is not blocked.Olekss
10/31/2017, 8:44 AMMarc Knaup
10/31/2017, 1:12 PMelizarov
11/01/2017, 9:54 PMdave08
11/01/2017, 10:02 PMproduce { }
for a BroadcastChannel
?dave08
11/01/2017, 10:09 PMactor { }
and still be thread safe, can the class member vars be used or do they have to be contained in the actor { }
function? And there must be an actor val to keep and return the actor.. one can't call send straight from the class. It would be nice to be able to derive from an actor abstract class...rocketraman
11/01/2017, 10:43 PMTristan Caron
11/04/2017, 2:09 PMhttp://reactivex.io/documentation/operators/images/S.PublishSubject.png▾
deviant
11/04/2017, 4:27 PMBroadcastChannel
crypto
11/05/2017, 1:50 AMraniejade
11/06/2017, 11:23 AMclass F {
suspend fun CoroutineScope.process() {
}
}
fun main(args: Array<String>) {
launch {
val f = F()
// unresolved reference
f.process()
}
}
jw
11/07/2017, 12:59 AMDeferred
(via CompletableDeferred
). Is there something else that offers this callback?elizarov
11/07/2017, 4:45 PMkrenvpravo
11/07/2017, 9:28 PMdeviant
11/09/2017, 6:33 PMdelay
on different platforms:
while delay(Long.MAX_VALUE)
works as expected in javafx
desktop project (infinite delay)
in android this line does nothing. but this one works:
delay(Long.MAX_VALUE / 2)
and i have no clue whyelizarov
11/14/2017, 4:27 PMMutex
sailxjx
11/15/2017, 8:24 AMsleep
can avoid putting too many messages in the queue.sailxjx
11/15/2017, 8:54 AMwhile (queue.size < 10000) {
queue.add(element)
}
sailxjx
11/15/2017, 8:54 AMneil
11/16/2017, 10:26 PMmarcinmoskala
11/17/2017, 7:33 AMmarcinmoskala
11/17/2017, 7:33 AMgildor
11/17/2017, 10:12 AMexpect suspend fun
or just suspend fun
?marcinmoskala
11/17/2017, 11:13 AMgildor
11/17/2017, 12:04 PM