synchronized access to hashmap

This commit is contained in:
Milos Kozak 2023-10-28 01:20:59 +02:00
parent 70db735476
commit 1f9f112f68

View file

@ -130,8 +130,10 @@ class StoreDataForDbImpl @Inject constructor(
private val pause = 1000L // to slow down db operations
fun <T> HashMap<T, Long>.inc(key: T) =
synchronized(this) {
if (containsKey(key)) merge(key, 1, Long::plus)
else put(key, 1)
}
override fun storeGlucoseValuesToDb() {
if (glucoseValues.isNotEmpty())