diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-08-25 11:11:48 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-08-26 12:51:59 +0000 |
commit | 5488ec35f689a5c9618e926154c094a91513b7a2 (patch) | |
tree | 54a8a47e8d538d66860d2b1a0fc3cb2ab87b8c61 /staging_vespalib | |
parent | 6a453219c2aa26f8895fe053aa9a67172d9e124e (diff) |
If you already have the lock you can just go ahead.
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++; |