diff options
author | Aleksandar Prokopec <aleksandar.prokopec@gmail.com> | 2015-02-11 20:40:35 +0100 |
---|---|---|
committer | Aleksandar Prokopec <aleksandar.prokopec@gmail.com> | 2015-02-18 23:34:24 +0100 |
commit | da2d4caae990bcb9fabb13e7a242b2b7babe0e0b (patch) | |
tree | 8d972c91aa4a3c4da1f2631689e1fc558cc80fc5 /src/library/scala/collection/mutable/MapLike.scala | |
parent | d14e065eb792a1eb77289f4a1320071c57c5d09b (diff) | |
download | scala-da2d4caae990bcb9fabb13e7a242b2b7babe0e0b.tar.gz scala-da2d4caae990bcb9fabb13e7a242b2b7babe0e0b.tar.bz2 scala-da2d4caae990bcb9fabb13e7a242b2b7babe0e0b.zip |
Fix SI-7943 -- make `TrieMap.getOrElseUpdate` atomic.
Override `getOrElseUpdate` method in `TrieMap`.
The signature and contract of this method corresponds closely to the
`computeIfAbsent` from `java.util.concurrent.ConcurrentMap`.
Eventually, `computeIfAbsent` should be added to
`scala.collection.concurrent.Map`.
Add tests.
Review by @Ichoran
Diffstat (limited to 'src/library/scala/collection/mutable/MapLike.scala')
-rw-r--r-- | src/library/scala/collection/mutable/MapLike.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala index af28df1b88..44af886cf5 100644 --- a/src/library/scala/collection/mutable/MapLike.scala +++ b/src/library/scala/collection/mutable/MapLike.scala @@ -178,6 +178,10 @@ trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]] * * Otherwise, computes value from given expression `op`, stores with key * in map and returns that value. + * + * Concurrent map implementations may evaluate the expression `op` + * multiple times, or may evaluate `op` without inserting the result. + * * @param key the key to test * @param op the computation yielding the value to associate with `key`, if * `key` is previously unbound. |