Address JDK8/JDK6 issues with computeIfAbsent
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
374d287d08
commit
3c4989b672
@@ -78,9 +78,14 @@ abstract class TypeRegistry<K : Any, V : Any> {
|
||||
}
|
||||
|
||||
fun <T : K> getId(kClass: KClass<T>): Int {
|
||||
return idPerType.computeIfAbsent(kClass) { idCounter.getAndIncrement() }
|
||||
return idPerType.customComputeIfAbsent(kClass) { idCounter.getAndIncrement() }
|
||||
}
|
||||
|
||||
abstract fun <T : K> ConcurrentHashMap<KClass<out K>, Int>.customComputeIfAbsent(
|
||||
kClass: KClass<T>,
|
||||
compute: (KClass<out K>) -> Int
|
||||
): Int
|
||||
|
||||
fun allValuesThreadUnsafeForRendering(): Map<KClass<out K>, Int> {
|
||||
return idPerType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user