pakoito
12/12/2017, 12:34 AMlouiscad
12/12/2017, 9:19 AMreceive()
without closing the channel, thus allowing subsequent attempts to get a value from the channel? I assume Channel
is not the right choice, but after reading the whole kotlinx.coroutines README, I did not find what I'm looking for.louiscad
12/12/2017, 10:55 AMMutex
is not reentrant? I'd love to have it for transactional stuff ("reliable writes" in BluetoothGatt). Is there an alternative? FYI, here's how I want to use it: https://gist.github.com/LouisCAD/88d06da6ae1caf04acbf6cd4fc1d5cac#file-gattconnection-kt-L56
EDIT: Added line of the relevant method in the linklittlelightcz
12/12/2017, 6:31 PMlittlelightcz
12/12/2017, 6:41 PMpakoito
12/13/2017, 1:12 AMdiesieben07
12/13/2017, 1:20 AMdiesieben07
12/13/2017, 1:22 AMdiesieben07
12/13/2017, 1:22 AMdiesieben07
12/13/2017, 1:23 AMlatch.countDown()
etc. can not happen in the coroutine, it must be in a different thread.dave08
12/13/2017, 8:30 AMelizarov
12/13/2017, 8:41 AMval connectionStatus = ConflatedBroadcastChannel<Boolean>(false)
to keep connected/disconnected status and then whenever I need to wait for it being connected I'd do connectionStatus.consume { while (!receive()) { /* do nothing */ } }
louiscad
12/13/2017, 8:56 AMasync
can also work if you (dangerously) want to also forget about potential exceptionsgildor
12/13/2017, 8:57 AMasync
shouldn’t be used if you don’t need result.
Probably make sense to write some style guide for kotlinx.coroutines (especially for API). We have so many useful idioms and best practices even nowelizarov
12/13/2017, 10:19 AMdekans
12/14/2017, 10:46 AMlouiscad
12/14/2017, 1:28 PMsend()
and offer()
when using RendezVousChannel
apart from the fact that offer()
is not suspended?galex
12/14/2017, 8:17 PMbillybong
12/15/2017, 9:28 AMelizarov
12/15/2017, 10:59 AMCompletableDeferred<Unit>()
as a latch. On one side you await()
it, on the other you do complete(Unit)
.r4zzz4k
12/15/2017, 1:39 PMzak.taccardi
12/15/2017, 4:06 PMCompletableFuture<T>
. But we have mixed kotlin/java code. Does that mean we cannot use Deffered<T>
?pakoito
12/15/2017, 8:20 PMnil2l
12/16/2017, 1:55 PMandyb
12/18/2017, 1:42 PMwithTimeout(1000){ incoming.receive() }
to do this but it seems to be hanging rather than timing out. Am I missing something?karelpeeters
12/18/2017, 4:18 PMfun main(args: Array<String>) = runBlocking {
myFun { if (it == 10) return@myFun }
}
suspend fun myFun(call: suspend (Int) -> Unit) {
for (i in 0 until 50) {
call(i)
println(i)
}
}
, but the coroutine just keeps running. I also tried coroutineContext.cancel()
on line 2, but that doesn't work either and throws an exception.karelpeeters
12/19/2017, 4:29 PMfun suspend(block: suspend () -> Unit) = block
works?Dan T
12/19/2017, 6:03 PMprivate fun processMessage(record: KafkaMessage) {
runBlocking {
launch {
handler.doSomething(record.data) // its implementation simply returns
log.debug("2") // NOT CALLED
}.join()
}
}
wineluis
12/19/2017, 9:46 PMlouiscad
12/19/2017, 9:51 PMsuspend
keyword, but in inline, it's implicitly always allowed, by design it seemslouiscad
12/19/2017, 9:51 PMsuspend
keyword, but in inline, it's implicitly always allowed, by design it seemsdave08
12/20/2017, 3:26 AMelizarov
12/20/2017, 6:58 AM