diff options
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/stllike/cache.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/cache.h b/staging_vespalib/src/vespa/vespalib/stllike/cache.h index e810cea73c6..948034db30d 100644 --- a/staging_vespalib/src/vespa/vespalib/stllike/cache.h +++ b/staging_vespalib/src/vespa/vespalib/stllike/cache.h @@ -91,7 +91,10 @@ public: /** * This simply erases the object from the cache. */ - void invalidate(const K & key); + void invalidate(const K & key) { + vespalib::LockGuard guard(_hashLock); + invalidate(guard, key); + } /** * Return the object with the given key. If it does not exist, the backing store will be consulted. @@ -125,6 +128,7 @@ public: protected: vespalib::LockGuard getGuard(); + void invalidate(const vespalib::LockGuard & guard, const K & key); private: /** * Called when an object is inserted, to see if the LRU should be removed. @@ -251,9 +255,9 @@ cache<P>::erase(const K & key) template< typename P > void -cache<P>::invalidate(const K & key) +cache<P>::invalidate(const vespalib::LockGuard & guard, const K & key) { - vespalib::LockGuard guard(_hashLock); + assert(guard.locks(_hashLock)); if (Lru::hasKey(key)) { _sizeBytes -= calcSize(key, (*this)[key]); _invalidate++; |