aboutsummaryrefslogtreecommitdiff
path: root/stage1/KeyLockedLazyCache.scala
diff options
context:
space:
mode:
Diffstat (limited to 'stage1/KeyLockedLazyCache.scala')
-rw-r--r--stage1/KeyLockedLazyCache.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/stage1/KeyLockedLazyCache.scala b/stage1/KeyLockedLazyCache.scala
index aca5f74..4eff5b2 100644
--- a/stage1/KeyLockedLazyCache.scala
+++ b/stage1/KeyLockedLazyCache.scala
@@ -47,8 +47,16 @@ final private[cbt] class KeyLockedLazyCache[Key <: AnyRef,Value <: AnyRef](
def remove( key: Key ) = keys.synchronized{
assert(keys containsKey key)
val lockableKey = keys get key
- keys.remove( key )
- assert(values containsKey lockableKey)
- values.remove( lockableKey )
+ lockableKey.synchronized{
+ if(values containsKey lockableKey){
+ // this is so values in the process of being replaced (which mean they have a key but no value)
+ // are not being removed
+ keys.remove( key )
+ values.remove( lockableKey )
+ }
+ }
+ }
+ def containsKey( key: Key ) = keys.synchronized{
+ keys containsKey key
}
}