FIR IDE: fix deadlock in symbol providers
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ internal class FirThreadSafeCache<K : Any, V, CONTEXT>(
|
||||
private val map = ConcurrentHashMap<K, Any>()
|
||||
|
||||
override fun getValue(key: K, context: CONTEXT): V =
|
||||
map.computeIfAbsentWithNullableValue(key) { createValue(it, context) }
|
||||
map.getOrPutWithNullableValue(key) { createValue(it, context) }
|
||||
|
||||
override fun getValueIfComputed(key: K): V? =
|
||||
map[key]?.nullValueToNull()
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ internal class FirThreadSafeCacheWithPostCompute<K : Any, V, CONTEXT, DATA>(
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getValue(key: K, context: CONTEXT): V =
|
||||
map.computeIfAbsent(key) {
|
||||
map.getOrPut(key) {
|
||||
ValueWithPostCompute(
|
||||
key,
|
||||
calculate = { createValue(it, context) },
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@ internal inline fun <VALUE> Any.nullValueToNull(): VALUE = when (this) {
|
||||
else -> this
|
||||
} as VALUE
|
||||
|
||||
internal inline fun <KEY : Any, RESULT> ConcurrentMap<KEY, Any>.computeIfAbsentWithNullableValue(
|
||||
internal inline fun <KEY : Any, RESULT> ConcurrentMap<KEY, Any>.getOrPutWithNullableValue(
|
||||
key: KEY,
|
||||
crossinline compute: (KEY) -> Any?
|
||||
): RESULT {
|
||||
val value = computeIfAbsent(key) { k -> compute(k) ?: NullValue }
|
||||
val value = getOrPut(key) { compute(key) ?: NullValue }
|
||||
return value.nullValueToNull()
|
||||
}
|
||||
Reference in New Issue
Block a user