aboutsummaryrefslogtreecommitdiff
path: root/stage1
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-03-30 21:19:39 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-03-30 21:19:39 -0400
commit8abb5c3ca85abc4d206afe39a2c4a98bc17560ba (patch)
treec0f0ddf7f25c8df8c137838fef74b719fe23f26f /stage1
parented39a00fa76ab7f8947cd85b26496130627a77e2 (diff)
downloadcbt-8abb5c3ca85abc4d206afe39a2c4a98bc17560ba.tar.gz
cbt-8abb5c3ca85abc4d206afe39a2c4a98bc17560ba.tar.bz2
cbt-8abb5c3ca85abc4d206afe39a2c4a98bc17560ba.zip
KeyLockedLazyCache was locking on the wrong object. Also added update method
Diffstat (limited to 'stage1')
-rw-r--r--stage1/KeyLockedLazyCache.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/stage1/KeyLockedLazyCache.scala b/stage1/KeyLockedLazyCache.scala
index 50c6f9e..aca5f74 100644
--- a/stage1/KeyLockedLazyCache.scala
+++ b/stage1/KeyLockedLazyCache.scala
@@ -30,13 +30,20 @@ final private[cbt] class KeyLockedLazyCache[Key <: AnyRef,Value <: AnyRef](
//logger.resolver("CACHE: \n" ++ keys.mkString("\n"))
// synchronizing on key only, so asking for a particular key does
// not block the whole cache, but just that cache entry
- key.synchronized{
+ lockableKey.synchronized{
if( ! (values containsKey lockableKey) ){
values.put( lockableKey, value )
}
values get lockableKey
}
}
+ def update( key: Key, value: Value ): Value = {
+ val lockableKey = keys get key
+ lockableKey.synchronized{
+ values.put( lockableKey, value )
+ value
+ }
+ }
def remove( key: Key ) = keys.synchronized{
assert(keys containsKey key)
val lockableKey = keys get key