[FIR] KTIJ-24156: Add test data
This commit is contained in:
committed by
Space Team
parent
af414cfb5e
commit
3a6e3290aa
+11
-1
@@ -13,8 +13,18 @@ internal class FirThreadSafeCache<K : Any, V, CONTEXT>(
|
||||
private val createValue: (K, CONTEXT) -> V
|
||||
) : FirCache<K, V, CONTEXT>() {
|
||||
|
||||
private val updating: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }
|
||||
|
||||
override fun getValue(key: K, context: CONTEXT): V =
|
||||
map.getOrPutWithNullableValue(key) { createValue(it, context) }
|
||||
map.getOrPutWithNullableValue(key) {
|
||||
if (updating.get()) error("Recursive update")
|
||||
try {
|
||||
updating.set(true)
|
||||
createValue(it, context)
|
||||
} finally {
|
||||
updating.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getValueIfComputed(key: K): V? =
|
||||
map[key]?.nullValueToNull()
|
||||
|
||||
Reference in New Issue
Block a user