viniciuslrangel
10/21/2018, 10:07 PMtapchicoma
10/22/2018, 6:55 AMdstarcev
10/22/2018, 9:20 AMdave08
10/22/2018, 10:21 AMval progress = Channel<Long>(Channel.CONFLATED)
val progressList = GlobalScope.async { progress.toList() }
runBlocking {
val progressResult = (0L..20L step 2).onEach { progress.offer(it) }
progress.close()
assertThat(progressResult.toList()).toBe(progressList.await())
}
progressList
is []...adibfara
10/22/2018, 11:16 AMNikky
10/22/2018, 11:36 AMcompile("something>name:version") { exclude(name = "excludedDependency") }
louiscad
10/22/2018, 11:41 AMlouiscad
10/22/2018, 12:41 PMcoroutineScope {
val daemonLikeJob = launch { while (true) /* Do sth until everything is done */ }
coroutineScope {
launch { /* do work */ }
launch { /* do work */ }
}
daemonLikeJob.cancel()
}
myanmarking
10/22/2018, 1:49 PMe: java.lang.IllegalStateException: failed to analyze: java.lang.ArrayIndexOutOfBoundsException
at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:125)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:161)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:57)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:96)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:441)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1020)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1062)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1019)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:440)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ArrayIndexOutOfBoundsException
patjackson52
10/22/2018, 2:24 PMSchadenfreude
10/22/2018, 2:27 PMenleur
10/22/2018, 8:33 PMnwh
10/22/2018, 9:01 PMwithContext
an extension on CoroutineScope
? Don't `launch`/`async` do more than just switch context?elect
10/22/2018, 9:41 PMClass 'kotlinx.coroutines.BuildersKt__Builders_commonKt' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler Class 'kotlinx.coroutines.CoroutineStart' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler Class 'kotlinx.coroutines.Job' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler Class 'kotlinx.coroutines.Job' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
spierce7
10/22/2018, 10:10 PMnewSingleThreadContext()
has been removed. What should I be using instead?spierce7
10/22/2018, 10:51 PMCoroutineContext
than this? I used to be able to do CoroutineContext(Dispatcher)
, but that doesn't seem to work anymore.spierce7
10/23/2018, 3:14 AMLimitingDispatcher
. Is this supported in a public API yet?Schadenfreude
10/23/2018, 10:00 AMLog.d("BillingManagerProvider", "suspendCoroutine: startConnection")
deviant
10/23/2018, 3:56 PM1.0.0-RC1
and now all my actors and channels marked as obsoleted api
. What apis should we use instead?rocketraman
10/23/2018, 5:12 PMSequence
. However, I also want to close the db cursor when the sequence has finished consuming. Is this a valid approach?
suspend fun findSomethings(...): Sequence<Something> {
val cursor = ...
return sequence {
cursor.use {
yieldAll(cursor.iterator())
}
}
}
spierce7
10/23/2018, 7:25 PMgildor
10/24/2018, 3:26 AMasync
builder, because you handle result only when call await
and don’t want to cancel all other coroutines and especially CoroutineScope of this UI component if one of our async jobs is failed, we can actually handle error when call await()
And you need non-supervisor Job and scope only in case if you want to run a few operations in parallel and want to cancel them if one of them failed, but it’s specific and explicit case, at least in usual UI development
So I have 2 points here:
1. Should coroutine guide recommend to use SupervisorJob for all UI components and not Job (what is now standard in documentation, for example check CoroutineScope
docs which use Job in Android Activity). Otherwise it can cause a lot of very subtle bugs when you use CoroutineScope for UI development.
2. We need some easy way to start non-supervisor scope. Now the only way to do that is CoroutineScope(coroutineContext + Job())
which is quite wordy way. maybe make sense to change coroutineScope
default implementation and create new Job instance if outer context contains SupervisorJob
If it make sense for someone, I would happy to create an issue and contribute, but maybe I missed some important use cases theresdeleuze
10/24/2018, 10:32 AMhttps://www.youtube.com/watch?v=nKJbDYRsO0s▾
fabianterhorst
10/24/2018, 10:47 AMmaven { url "<https://dl.bintray.com/kotlin/kotlinx/>" }
0.30.2-eap13 works just fine.kirillrakhman
10/24/2018, 1:42 PMlukaswelte
10/24/2018, 1:47 PM<http://Dispatchers.IO|Dispatchers.IO>
or a newFixedThreadPoolContext
with the number of threads being the max DB pool size?Jaroslav
10/24/2018, 2:20 PMKotlinx_coroutines_core_nativeCoroutineDispatcher
in my ios framework. I’m using 1.0.0-RC1 coroutines. Maybe it changed the name or something?louiscad
10/24/2018, 2:22 PMlaunch {
val someWorkAsync = async {
throw CustomException()
}
delay(100)
try {
someWorkAsync.await()
} catch (e: CustomException) {
println("Handled it! $e")
}
}
If I understood correctly, now, the whole scope is cancelled, even though the exception is handled properly when calling await()
. How can I get the previous behavior? Create a Job
that has scope's job as parent, and use it for async(…) { … }
?dave08
10/24/2018, 5:06 PMIterable.asReceiveChannel()
was deprecated (in 0.30.2) contrary to the other channel operators that were just marked obsolete. Any reason why? Even Rx has such adapters, and this could come in handy in Unit testing for mocking...bolot
10/24/2018, 9:36 PMkotlin.Result cannot be cast to MyType
? I'm trying to use Result
with LiveData, doing something like this: liveData.value = runCatching { useCase().await() }
, which is then used in liveData.observe
as result.onSuccess { } .onFailure { }
(Kotlin version 1.3.0-rc-190)bolot
10/24/2018, 9:36 PMkotlin.Result cannot be cast to MyType
? I'm trying to use Result
with LiveData, doing something like this: liveData.value = runCatching { useCase().await() }
, which is then used in liveData.observe
as result.onSuccess { } .onFailure { }
(Kotlin version 1.3.0-rc-190)gildor
10/24/2018, 11:15 PMbolot
10/24/2018, 11:21 PMamatkivskiy
11/25/2018, 10:02 AM