https://kotlinlang.org logo
Docs
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
  • l

    louiscad

    06/28/2018, 3:07 PM
    Is there a possibility that recent kotlinx.coroutines versions (e.g. 0.23.3) play worse with proguard than previous ones (like 0.22.5)?
    e
    • 2
    • 2
  • k

    kenkyee

    06/29/2018, 7:42 PM
    Direct invocation is always faster IMHO. Surprised you are doing that kind of low level stuff in Kotlin
    ➕ 1
    d
    m
    • 3
    • 2
  • c

    coder82

    07/01/2018, 8:27 AM
    I was thinking to a Channel but seems laborious
    g
    • 2
    • 2
  • c

    coder82

    07/01/2018, 8:30 AM
    I am a huge fun of suspendCoroutine but sometimes I just to have a callback which signals me a value changed, I guess I need to provide it myself
    g
    • 2
    • 1
  • c

    coder82

    07/02/2018, 9:46 PM
    are there unbounded channels?
    j
    • 2
    • 3
  • i

    igorvd

    07/03/2018, 1:34 PM
    Anyone have a good use case for using channels on Android? I'm trying to learn it, but I can't think in any good reason to use it on Android (Not saying that it doesn't exists tho)
    l
    j
    +2
    • 5
    • 13
  • s

    spand

    07/04/2018, 5:31 AM
    In this example of actors from the guide. What ensures the memory safety of the
    counter
    variable ? ie. that the latest write to
    counter
    is always read by the next processing thread?
    fun counterActor() = actor<CounterMsg> {
        var counter = 0 // actor state
        for (msg in channel) { // iterate over incoming messages
            when (msg) {
                is IncCounter -> counter++
                is GetCounter -> msg.response.complete(counter)
            }
        }
    }
    l
    e
    • 3
    • 5
  • c

    coder82

    07/04/2018, 8:22 AM
    but for that I needed to add maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
    g
    d
    e
    • 4
    • 8
  • l

    louiscad

    07/05/2018, 8:17 AM
    Hi, anyone knows why there's no
    onEach
    function for
    ReceiveChannel
    ?
    s
    w
    • 3
    • 5
  • l

    louiscad

    07/05/2018, 8:46 AM
    Also, is there any alternative?
    e
    • 2
    • 5
  • r

    redrield

    07/07/2018, 8:44 PM
    Specifically I'm talking about getResult() from firebase firestore. It throws an exception if the task isn't completed, and they have "add listener" crap that you can use, but I'd like to just call something like getResult in the commonpool context and have it suspend until the task is completed
    g
    i
    • 3
    • 4
  • s

    Slackbot

    07/08/2018, 4:59 PM
    This message was deleted.
    v
    h
    +2
    • 5
    • 11
  • r

    rahulrav

    07/08/2018, 5:29 PM
    I am using coroutines on Google App Engine. I have a coroutine dispatcher which uses the defined executor:
    private fun defaultExecutor(): ThreadPoolExecutor {
        val maxPoolSize = Runtime.getRuntime().availableProcessors() * 3
        val keepAliveTime = 2L // in seconds
        val queue = LinkedBlockingQueue<Runnable>()
        return ThreadPoolExecutor(0, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, queue, ThreadManager.currentRequestThreadFactory())
      }
    Note the use of the
    ThreadManager.currentThreadRequestFactory()
    . Every time I invoke a
    suspend
    function I ensure that it is accompanied by a
    withContext(...)
    which uses the above defined coroutine dispatcher. I see that sometimes, I get `Exception`s on App Engine, claiming I am trying to get an instance of supporting services (like Datastore or Memcache) on a thread which was not created by their thread factory (
    ThreadManager
    ). This typically happens in a coroutine's
    resume
    method. Any ideas on what I might be doing wrong ?
    e
    l
    • 3
    • 6
  • n

    noncom

    07/10/2018, 1:46 PM
    I want to use a language interpreter written for Java (LuaJ) and allow it to launch program execution (interpretation) on Kotlin coroutines. As far as I understand, it is impossible to get that functionality by just using the library from Kotlin. What would be the easiest way to make it work with Kotlin?
    g
    • 2
    • 12
  • n

    noncom

    07/10/2018, 1:47 PM
    notice: I mean that I want to use Kotlin coroutines to launch many interpreters simultaneously, that is not about Lua coroutines
    g
    l
    • 3
    • 15
  • r

    rocketraman

    07/10/2018, 5:18 PM
    Why is the last
    log
    showing a
    DefaultExecutor
    context and not
    SINGLE-THREAD
    ?
    e
    l
    d
    • 4
    • 18
  • n

    nwh

    07/11/2018, 10:50 PM
    I have a process that has multiple steps. Think: fetching data from the database, doing some lookups, asking for input, and then performing some actions. Any of these actions could result in the entire process being cancelled (ideally with a specific error), but I also want to be able to relay the progress back. Is an actor a good use case for this?
    l
    • 2
    • 1
  • j

    Jonathan Walsh

    07/11/2018, 11:07 PM
    Are there any tools, released or otherwise, that help debug coroutine stack-traces?
    🤔 2
    g
    • 2
    • 5
  • b

    bj0

    07/11/2018, 11:11 PM
    @nwh an actor would be a fine approach if they need to be serially executed
    n
    d
    l
    • 4
    • 11
  • g

    groostav

    07/13/2018, 5:34 AM
    can we add this to the documentation?
    e
    • 2
    • 3
  • l

    louiscad

    07/13/2018, 12:42 PM
    Hi, do Android people there know if it's possible to make a Handler run in CommonPool?
    d
    m
    • 3
    • 4
  • d

    Dominaezzz

    07/15/2018, 5:59 PM
    Is it possible to wrap an async api based on polling (instead of callbacks) in a suspend function(or coroutine)? ...without another thread of course. So only
    makeRequest(): Request
    ,
    Request.isDone(): Boolean
    ,
    Request.cancel()
    and
    Request.getResult(): Result
    are available.
    e
    • 2
    • 2
  • m

    mcastiblanco

    07/16/2018, 12:57 AM
    @elizarov I have a question about exception propagation. I can see that
    handleCoroutineException()
    tries to forward/handle the exceptions. So my question is: is the call to
    handleCoroutineException()
    generated by the compiler? maybe as part of the
    Continuation
    or by wrapping the state machine with a trycatch?
    e
    • 2
    • 1
  • l

    louiscad

    07/16/2018, 7:34 AM
    I am observing intriguing behavior with kotlinx.coroutines 0.23.4 where I call
    job.cancel(IllegalStateException(...))
    from a callback, catch exceptions from the parent coroutine, but still get my app crashing. I replicated the issue in some tests, and the catch block is hit, but it seems the Exception is thrown no matter if it was caught in the parent coroutine. Is this really intended?
    e
    g
    • 3
    • 33
  • l

    louiscad

    07/16/2018, 3:12 PM
    Has anyone experienced Android instrumented test methods that have
    runBlocking
    as their body, never returning while the inner coroutine is run successfully?
    w
    d
    +2
    • 5
    • 21
  • n

    nwh

    07/18/2018, 5:40 PM
    Ahh, that's what I didn't understand, I think. If I used an actor, I would pass the channel it created to the task. It wouldn't go the other way, right?
    w
    • 2
    • 2
  • l

    louiscad

    07/20/2018, 6:08 AM
    @groostav Use a private constructor that takes the already initialized data, and in the companion object, declare a
    suspend operator fun
    that does what you need without blocking.
    g
    • 2
    • 1
  • g

    giso

    07/20/2018, 9:49 AM
    I would love to use coroutines in an OSGI bundle. Are there any plans to publish a coroutines bundle or include it into the kotlin bundle?
    e
    • 2
    • 2
  • n

    nwh

    07/20/2018, 7:39 PM
    I'm almost certain I know the answer to this, but just in case: Is it possible to specify the type of CoroutineScope for a given CoroutineDispatcher or a CoroutineContext? For example, a context/dispatcher for a database that will pass the connection to the scope?
    e
    g
    g
    • 4
    • 4
  • s

    spierce7

    07/21/2018, 3:10 AM
    My team is already busy filling in other library gaps we have for MPP. We'll actually be pretty happy when we get kotlinx.coroutines that can work on background threads for kotlin/native. I'm more or less just curious when we were going to see something materialize on the cold streams front. I was expecting the answer of Q4 this year or Q1 2019. I'm fine with waiting.
    v
    • 2
    • 2
Powered by Linen
Title
s

spierce7

07/21/2018, 3:10 AM
My team is already busy filling in other library gaps we have for MPP. We'll actually be pretty happy when we get kotlinx.coroutines that can work on background threads for kotlin/native. I'm more or less just curious when we were going to see something materialize on the cold streams front. I was expecting the answer of Q4 this year or Q1 2019. I'm fine with waiting.
v

Vsevolod Tolstopyatov [JB]

07/21/2018, 12:31 PM
Hi,
My team is already busy filling in other library gaps we have for MPP
Could you please elaborate what is missing (and is crucial for you)? We have a lot of thoughts what should be done for MPP (serialization, hashing, specific data structures, Guava stuff, proper CLI etc.), but it’s just too much. And you are one of the earliest adopters of iOS+Android mpp, it would be great to hear your opinion
I’m more or less just curious when we were going to see something materialize on the cold streams front
I think I’ll start prototyping it in the middle of Q3. Our priority is K/N coroutines and structured concurrency (https://github.com/Kotlin/kotlinx.coroutines/issues/410) now. The latter is important to get done because it affects every subsequent design decision and will break backward compatibility for basically every coroutine builder (and we can’t afford that after
1.0
version)
View count: 3