From 9f9033870c3a9406f6361fa09e289db9ed22001b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 25 Sep 2018 08:49:50 +0300 Subject: [PATCH] Add a note about non-atomic behavior of MutableMap.getOrPut #KT-13821 --- libraries/stdlib/src/kotlin/collections/Maps.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 674574f3e21..0e13baa3c15 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -297,6 +297,8 @@ public fun Map.getValue(key: K): V = getOrImplicitDefault(key) * Returns the value for the given key. If the key is not found in the map, calls the [defaultValue] function, * puts its result into the map under the given key and returns it. * + * Note that the operation is not guaranteed to be atomic if the map is being modified concurrently. + * * @sample samples.collections.Maps.Usage.getOrPut */ public inline fun MutableMap.getOrPut(key: K, defaultValue: () -> V): V {