https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
coroutines
  • w

    wcaokaze

    05/30/2018, 10:15 AM
    Can we get a Job that is already completed?
    a
    l
    g
    • 4
    • 12
  • s

    spand

    05/30/2018, 11:45 AM
    How would one create something like Promise.race() with coroutines?
    d
    • 2
    • 2
  • s

    spierce7

    05/31/2018, 5:21 AM
    The Kotlinx.coroutines repo hasn't been getting any love for a month+ now. Any idea what's going on? It looked like MPP work was progressing, but hasn't been touched for a while now.
    l
    v
    • 3
    • 9
  • d

    Darshan Mistry

    05/31/2018, 11:30 AM
    Hello, I am new in Kotlin Development. Can anyone suggest me good sources to learn Kotlin coroutines in android?
    l
    m
    t
    • 4
    • 7
  • d

    dave08

    05/31/2018, 5:25 PM
    I was never too clear on how to cleanly handle exceptions with Channels in the first place, is there maybe a good article or reference on the subject (apart from the guides on Github that don't really go into best practices the different cases that could occur...)
    l
    v
    • 3
    • 4
  • t

    thevery

    05/31/2018, 9:32 PM
    Well, rx2 dependencies overhead after proguard is about 2.5k in my project and coroutines is only ~0.5k (even with coroutines-rx2), but the initial question is still actual: why coroutines generates more methods and what to do with it?
    g
    e
    • 3
    • 5
  • j

    jw

    06/01/2018, 2:12 PM
    is there something preventing actors from being included in multiplatform channels?
    v
    d
    +2
    • 5
    • 5
  • t

    thevery

    06/03/2018, 1:37 AM
    ok, finally managed to extract minimal sample to demonstrate another dexcount problem with coroutines:
    package com.thevery.sample.dexcount
    
    import android.support.annotation.Keep
    import kotlinx.coroutines.experimental.CommonPool
    import kotlinx.coroutines.experimental.launch
    
    class DexCountHelper {
    
        private val labelsToMark = setOf<String>()
        private val originalState = mapOf<String, MarkedState>()
    
        enum class MarkedState {
            MARKED_ALL, MARKED_SOME, MARKED_NONE
        }
    
        @Keep
        fun coroutines() {
            val finalLabelToMark = labelsToMark.filter { lid -> originalState[lid] != MarkedState.MARKED_ALL }
    
            launch(CommonPool) {
                // +2 methods here :(
                // val finalLabelToMark = labelsToMark.filter { lid -> originalState[lid] != MarkedState.MARKED_ALL }
                println("finalLabelToMark = $finalLabelToMark")
            }
        }
    }
    v
    • 2
    • 2
  • v

    voddan

    06/04/2018, 6:25 AM
    A trick question: how does
    CommonPool + CoroutineName("hi")
    behaves? Does it allocate new threads (if yes, how many) or reuses threads from
    CommonPool
    ? How come?
    v
    • 2
    • 1
  • g

    gildor

    06/04/2018, 6:31 AM
    reuses threads from CommonPool, why do you think this is tricky?
    v
    v
    +2
    • 5
    • 40
  • l

    Lex Luthra

    06/05/2018, 3:42 AM
    does anyone know where things currently stand with Spring Boot / WebFlux / Coroutines integration? I saw Konrad Kaminsky's presentation earlier in the year but it looks like his project has been inactive for a few months now..
    g
    s
    • 3
    • 4
  • o

    Olekss

    06/05/2018, 5:57 AM
    hey do I understand correctly that launch { x = async {...};y=async{}; x.await(); y.await()} will try to take 3 threads from ForkJoinPool and in case of 1core computer 2nd async simply will not start until first finished even without "await"?
    g
    l
    • 3
    • 84
  • s

    sdeleuze

    06/05/2018, 1:06 PM
    Is there any known issues with Coroutines + function references?
    i
    • 2
    • 2
  • g

    gildor

    06/07/2018, 8:25 AM
    val job = launch {
            println("Do something")
        }
        
        job.join()
    
        assertTrue(job.isCompleted)
        assertTrue(!job.isCancelled)
        println("isCompleted ${job.isCompleted}, isCancelled ${job.isCancelled}") 
        //output: isCompleted true, isCancelled false
    s
    • 2
    • 6
  • e

    elizarov

    06/07/2018, 8:30 AM
    @spand It does not really matter if
    Job()
    had completed “normally” or “was cancelled”. You can tell the difference (between normal completion and cancellation) with
    isCancelled
    and that is the only difference. Just use
    cancel()
    in all cases and don’t use
    isCancelled
    .
    g
    s
    • 3
    • 7
  • g

    gildor

    06/07/2018, 4:29 PM
    You can use non-blocking network API, such as Java.nio
    a
    m
    d
    • 4
    • 9
  • l

    Lex Luthra

    06/08/2018, 4:40 AM
    Is there a way to configure Jacoco (code coverage) to ignore Kotlin coroutines generated code?
    g
    e
    • 3
    • 4
  • a

    acando86

    06/08/2018, 11:45 AM
    What are the best practises for exception handling inside of an actors? Any unhandled exception gets propagated to the actors' channel, so the actor will not react to further incoming messages. I understand the more the codebase is using actors, the more this allows to model the entire architecture in a different way and handle the recovery logic at a higher level. But sometimes I might be using actors just in a specific area of the codebase to save a state without having to deal with thread confinement myself (eg, like the example of the counter in the kotlin docs), and in such a case maybe (?) i want to protect the actor from failures with some explicit try catch inside the actor itself. Is this a bad idea? Are there any preferred patterns to dead with this? Any suggestion?
    e
    p
    • 3
    • 3
  • z

    zak.taccardi

    06/08/2018, 9:28 PM
    I need a
    Channel<T>
    that supports consuming items from it, but one that can be unsubscribed from and remain open. Is this possible? https://stackoverflow.com/questions/50768585/consumable-channel
    l
    • 2
    • 1
  • d

    Daniel Tam

    06/09/2018, 3:57 PM
    is there any way to poll/receive from a channel without consuming the element? like peeking at the front of a queue
    v
    l
    w
    • 4
    • 5
  • t

    thomasnield

    06/09/2018, 7:29 PM
    Hey all, I got a fun challenge for purposes of data science and operations research problems. Is there a way to parallelize this binary tree traversing problem? I have tried to use coroutines but I frequently run into two problems: 1) Waiting for the entire search to complete 2) Memory issues for larger values of
    treeRowCount
    . Thoughts on an implementation?
    v
    • 2
    • 4
  • w

    wickedev

    06/10/2018, 8:39 AM
    I was installed kotlinx-coroutines-core via npm, but can not found the atomicfu.js dependency because atomicfu is not in the npm repository. Can be solved?
    e
    • 2
    • 1
  • e

    elizarov

    06/11/2018, 8:14 AM
    @katokay Some discussion and additional links can be found here: https://github.com/Kotlin/kotlinx.coroutines/issues/119
    k
    o
    • 3
    • 2
  • g

    gildor

    06/11/2018, 8:48 AM
    @elizarov Current implementation of channels allocates a few object on each item in a channel. For example this is what ConflatedBraodcastChannel allocates for each `send(value)`:
    CancallableContunuationImpl
    ,
    AbstractChannel.ReceiveHasNext
    ,
    ChildContinuation
    ,
    ConflatedBroadcastChannel.State
    and lambda of
    ReceiveChannel.consume
    . Isn’t this too much? It’s fine for many cases. But if you want to work with UI drawing events (60 per second in case of Android) it looks like significant overhead
    ➕ 1
    e
    • 2
    • 17
  • e

    elizarov

    06/11/2018, 9:20 AM
    📣
    kotlinx.coroutines
    version
    0.23.1
    fixes JS version in NPM (adds missing dependency) and introduces
    broadcast
    builder for JVM&JS. https://github.com/Kotlin/kotlinx.coroutines/releases/tag/0.23.1
    🎉 9
    s
    • 2
    • 1
  • l

    louiscad

    06/11/2018, 12:49 PM
    Hi, anyone is using the
    select
    expression? If yes, for what use cases?
    d
    m
    b
    • 4
    • 8
  • w

    withoutclass

    06/12/2018, 2:29 PM
    there are a lot of gotchas with channels where they are shut down unexpectedly, until you dig into the doc and see that it says that’s what will happen
    e
    d
    g
    • 4
    • 16
  • d

    Daniel Tam

    06/13/2018, 6:11 AM
    just to make absolutely certain, it's safe to send concurrently to the same channel from different threads right?
    l
    b
    • 3
    • 3
  • r

    rattleshirt

    06/13/2018, 9:58 AM
    Anyone else ran into this:
    java.lang.NoSuchMethodError: No virtual method refresh(Lkotlin/Unit;Lkotlin/coroutines/experimental/Continuation;)Ljava/lang/Object;
    when calling a suspend fun with param
    Unit
    ? Is this a coroutine or dex’ing issue?
    l
    • 2
    • 13
  • d

    Daniel Tam

    06/13/2018, 11:01 AM
    is there a good way of debugging coroutines? I know that that's quite a general question but is there some way that I can view the memory/variables of every method that is currently suspended if I set a breakpoint somewhere? I can run everything on a single threaded context if that makes anything easier
    s
    • 2
    • 2
Powered by Linen
Title
d

Daniel Tam

06/13/2018, 11:01 AM
is there a good way of debugging coroutines? I know that that's quite a general question but is there some way that I can view the memory/variables of every method that is currently suspended if I set a breakpoint somewhere? I can run everything on a single threaded context if that makes anything easier
s

spand

06/13/2018, 11:17 AM
If you run it on a
TestCoroutineContext
then I think some of them are in the
queue
property. Not sure if it is all of them
d

Daniel Tam

06/13/2018, 12:25 PM
hmm that's not quite what I meant but I'll keep that in mind nonetheless!
View count: 2