elizarov
03/12/2018, 4:21 PMenleur
03/12/2018, 6:01 PMConflatedBroadcastChannel
for broadcasting?jonathan
03/14/2018, 2:23 AMkasper.kondzielski
03/14/2018, 11:48 AMdave08
03/15/2018, 11:49 AMfun registerBroadcastReceiver(context: Context, intentFilter: IntentFilter): ReceiveChannel<Intent> =
produce(capacity = Channel.UNLIMITED) {
var broadcastReceiver:BroadcastReceiver? = null
try {
broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
offer(intent)
}
}.also { context.registerReceiver(it, intentFilter) }
} catch(e: CancellationException) {
context.unregisterReceiver(broadcastReceiver)
}
}
But with this the Channel is obviously closed right away... How could we implement this otherwise? We don't want the user of the function to have to unregister the receiver, but rather that when the channel is cancelled, it should automatically be unregistered...dave08
03/15/2018, 1:40 PMany
but the channel was closed before the offer
in the callback being wrapped...Jonathan
03/15/2018, 2:33 PMConsumable<E>.first()
for the Consumable
interface you propose? https://github.com/Kotlin/kotlinx.coroutines/pull/274#issuecomment-373393257Jonathan
03/15/2018, 6:13 PMlouiscad
03/16/2018, 2:49 PMsuspend
lambda "creator" without parameters, but didn't bring one with a single parameter ?
I can easily write one: inline fun <T, R> suspend(noinline block: suspend (T) -> R): suspend (T) -> R = block
Jonathan
03/16/2018, 4:56 PMelizarov
03/16/2018, 6:40 PMdsgryazin
03/17/2018, 3:25 PMTestScheduler
in Rx, making time shifting in test a breeze.
I'd expect a special CoroutineDispatcher
for testing reasons.
I've looked through the tests in coroutines-core
repository, but did not find examples there. Moreover it's full of realtime delays delay(100)
.
The case is testing UI-sensitive code, where delays can be impermissibly long.Evgeniy Zaharov
03/20/2018, 8:06 AMbenny.huo
03/21/2018, 9:09 AMhttps://kotlinlang.slack.com/files/U4W041P5F/F9UEZA1QX/image.png▾
uhe
03/21/2018, 1:05 PMTristan Caron
03/21/2018, 3:22 PM// From Ktor
get("/longtask") {
call.respondText("OK")
runLongTask(settings) // Returns a Job
}
What I would like is, when /longtask
is called for the first time, call the function runLongTask
, but if it's called a second time, and runLongTask
from the first call is not finished yet, to run it again. Not at all.alucard
03/23/2018, 1:45 PMjw
03/23/2018, 1:54 PMTristan Caron
03/27/2018, 3:01 PMmarcoferrer
03/28/2018, 7:39 PMmmaillot
03/29/2018, 2:59 PMDeferred
then call await()
:
data.map {
async(Bg) { it.httpGet().response() }
}.map {
it.await()
}
Is it the good approach ?rocketraman
03/29/2018, 5:47 PMcomputations.forEach { it.await() }.map(tToR)
?kevin.cianfarini
03/30/2018, 3:29 AMDmytro Danylyk
03/30/2018, 10:55 AMvuserChannel
.filterNotNull()
.map(CommonPool) { it.userName }
.consumeEach(UI) { user_name.text = it }
travis
03/31/2018, 12:36 AMTimeoutCancellationException
is being used as a signal for cancelling the parent Coroutine context, so the exception message (and stacktrace) are suppressed?Dmytro Danylyk
04/01/2018, 3:58 AMsuspend
keyword is to mark suspension points, but it also serve as “marker” for caller: this function is compiled to function with continuation (callback) = this function has suspension point = this function may block your threadgildor
04/02/2018, 3:39 AMnewSingleThreadContext
and newFixedThreadPoolContext
Also coroutine context is not only dispatcher (context type that controls execution strategy)Felix
04/03/2018, 5:25 PMDeferred
or CompletableFuture
). In my understanding, they convert from the "suspend" world into the "classical world". In this context, is there any terminology to classify the functions (typically extensions functions such as await
) that do the reverse: convert from the "classical" world into the "suspend" world, i.e., suspend functions receive a representation of an asynchronous computation and return a value?Felix
04/04/2018, 11:43 AMFelix
04/04/2018, 6:55 PM