I have a mutableMap and two functions the queue function is getting called from different origins. But somehow the map is always empty if I modify it in these functions?
Code:
is not safe to mutate from multiple threads without some form of synchronization
j
Jan
09/10/2021, 8:12 PM
yes I also though something like that but I haven't found a working thread safe hashmap
Jan
09/10/2021, 8:12 PM
(kotlin multiplatform)
z
Zach Klippenstein (he/him) [MOD]
09/10/2021, 9:38 PM
Ah, yea i’m not aware of any multiplatform threadsafe implementations. You could use a mutex or something, not sure if there are multi-platform impls of that either. Another approach would be an immutable map with atomicfu.
s
Stephan Schroeder
09/11/2021, 7:22 PM
not having threadsafe implementations in multiplatform might be due to the old memory manager in native?!? So maybe this changes soon-ish after the new memory manager goes live??
Kotlin 1.6, which might be release around the end of october, will at least contain a preview of that new memory manager. more on this see: https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/