https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

niqo01

11/22/2019, 10:49 PM
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.
a

Arkadii Ivanov

11/22/2019, 11:48 PM
I use just AtomicReference<List>
👍 1
k

kpgalligan

11/22/2019, 11:50 PM
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

11/23/2019, 12:57 AM
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
k

kpgalligan

11/23/2019, 1:09 AM
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.
👍 1
481 Views