rook
11/01/2018, 8:26 PMreturn@launch
, thanksnwh
11/01/2018, 9:48 PMwithContext
create a new (child) scope?mp
11/02/2018, 4:39 PMjavad
11/02/2018, 4:48 PMSingle.await()
? The official lib only supports RxJava 2 😞Dias
11/02/2018, 5:52 PMmarcelo
11/02/2018, 10:11 PMasync
and await
?Zach Klippenstein (he/him) [MOD]
11/02/2018, 10:35 PMsuspend
, it shouldn’t block the current thread”. Do you remember where that was (if it was in fact something you did say)?nwh
11/03/2018, 12:13 AMsuspend
function, shouldn't the current CoroutineScope
be accessible? Since it had to be invoked from some type of scope?nulldev
11/03/2018, 9:20 PMselect
on send
. I just allocated an output and input channel for each worker:
suspend fun invoke(input: InputType): OutputType {
return selectUnbiased {
for(worker in runningWorkers) {
worker.inputChannel.onSend(input) {
worker.outputChannel.receive()
}
}
}
}
DALDEI
11/04/2018, 3:46 AMKulwinder Singh
11/04/2018, 9:47 AMinit
and getLastState
are suspend
function ?acando86
11/04/2018, 4:19 PMlouiscad
11/05/2018, 9:36 AMselect
clause to select between two user inputs (two button clicks). Should I implement the select clause myself in an extension function, or should I transform the button clicks to a channel, and then use the already existing select clause implementations?aaverin
11/05/2018, 10:47 AMTolriq
11/05/2018, 10:59 AMinterface Host {
suspend fun getMovies() : List<Movies>
suspend fun setWatched(movie:Movie) : Boolean
.....
}
Imagine a lot more functions. At any given moment there should be no more than X functions running.
Ideally the limit should only apply to the actual server communication and the transformation of received data, should not be limited to allow faster command enqueing.
The interface does implement close() that should also cancel all running coroutines for the host.
My solution with blocking calls, would be to have a dedicated thread pool as dispatcher and use withcontext for the network call, but this is not efficient and no more works if some of the calls are non blocking and can switch to IO for example.
I'd really appreciate some help on how to apprehend this needs, as it's major refactoring so needs to be done correctly 🙂julioyg
11/05/2018, 11:48 AMfun doSomeStuff() : Deferred<String> = async { /*doing something*/}
, should that be an extension function of a coroutineContext
as it starts a coroutine?wcaokaze
11/05/2018, 11:59 AMlaunch {
try {
async { throw IOException() }.await()
} catch (e: IOException) {
}
}
I get an uncaught IOException. What is wrong?Jaroslav
11/05/2018, 1:40 PMInteface T { suspend fun A: String}
Class S{
suspend fun B(){
val result = t.A()
}
}
I want to change fun A to return Deferred<String> object, but not sure how to change val result = t.A()
so the result would be the same as if A was suspend function.marcelo
11/05/2018, 2:08 PMrenderMetricTimer.tagVal(renderTemplate.mediaType.name).time {
but clearly it gives the error
suspend function needs to be call in a subroutine.This function returns a value (
map
). Not sure how can I do this.marcelo
11/05/2018, 2:20 PMreturn templates.map { renderTemplatePath ->
runBlocking {
val result = async {
renderMetricTimer.tagVal(package).time {
//code
}
}
result.await()
}.toSet()
}
Obviously, I am new to coroutines, but this seems like a lot of coroutine builders, no?oshai
11/05/2018, 3:26 PMCompleteableFuture
.
So I thought about converting it to either suspend fun
by using the await
extension.
Another option is to create methods that return Deferred
.
What do you think is a better approach?littlelightcz
11/05/2018, 6:10 PMcancel()
on the outermost parent's Job
?marcelo
11/05/2018, 6:11 PMreturn@time
? Is it because my suspended coroutine is called time? Also, why can't I do the following:
return when(process.exitValue()) {
0 -> {
return resultsAdapter.fromJson(scanResults)
...
}
droidrcc
11/05/2018, 6:22 PMSteven McLaughlin
11/05/2018, 9:05 PMhow do kotlin coroutines work? i.e. is it just a state machine on top of Java's threadpool?I don't really know anything about the internals. I thought maybe someone in here would have some insight
nwh
11/05/2018, 9:38 PMGlobalScope
, or should I use the most localized scope I can, just so the processes stay organized?nwh
11/05/2018, 9:43 PMCoroutineScope
not used for what is essentially an on-going Job
with a lifecycle? That's how I've always thought about it (I believe it was mentioned in a kotlinconf talk)karelpeeters
11/05/2018, 10:06 PMprivate val loop = iterator {
for (i in 0 until 10) {
println(i)
yield(Unit)
}
}
fun doIteration() {
loop.next()
}
vitrox1
11/06/2018, 8:42 AMdevbridie
11/06/2018, 12:22 PMsuspend fun main() {}
.devbridie
11/06/2018, 12:22 PMsuspend fun main() {}
.elizarov
11/06/2018, 12:41 PM