Is there an equivalent of java CopyOnWriteArrayLis...
# multiplatform
n
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
I use just AtomicReference<List>
👍 1
k
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
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
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
594 Views