Matthew Adams
07/07/2023, 4:30 PMMutableMap
that can be safely used when accessed from multiple `suspend fun`s? We’re seeing unpredictable behavior, where keys that should exist don’t. ConcurrentHashMap
displays the same behavior as mutableMapOf()
in our case.Joffrey
07/07/2023, 4:31 PMConcurrentHashMap
only makes its own operations atomic, but if your own business logic needs to have atomic sections, you might have to use a Mutex
manually. Could you please share a piece of code reproducing your problem?Matthew Adams
07/07/2023, 4:32 PMCLOVIS
07/10/2023, 10:27 AMmap[5] = someTransformation(map[5])
then you always have a risk two concurrent executions will corrupt each other, no matter the type of map you use.
In these cases, the only thing you can do is use a Mutex everywhere