Thread
#multiplatform
    n

    niqo01

    2 years ago
    Is there an equivalent of java CopyOnWriteArrayList in common code? I am trying to find an easy way to share a mutable collection across threads in common code.
    Arkadii Ivanov

    Arkadii Ivanov

    2 years ago
    I use just AtomicReference<List>
    kpgalligan

    kpgalligan

    2 years ago
    COW list also just uses AtomicReference, but still 🙂
    Expect/actual on jvm uses a jvm version, which would have better performance (most likely): https://github.com/touchlab/Stately/blob/master/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/Functions.kt#L24
    n

    niqo01

    2 years ago
    Looks like exactly what I was looking for thanks.
    @kpgalligan My mpp project has android and js targets, it looks like the
    js()
    target is commented in stately-collections
    kpgalligan

    kpgalligan

    2 years ago
    Ah, yeah. Stately started as a native mobile thing. Collections got moved out to a separate module in preparation for a faster implementation (probably early 2020). Core stately has JS, but I never went back and implemented collections.