diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-08 12:17:48 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-08 12:17:48 +0000 |
commit | 2b9620a0b2290d36685289028ddcf11559f6a38e (patch) | |
tree | 3053ab2ec400183f92f783f6150b20d84b21fb76 | |
parent | 341ffc2689341fa7f2116b5a9b304e11d8283ad0 (diff) |
nullptr => not locked, otherwise locked.
-rw-r--r-- | storage/src/tests/bucketdb/lockablemaptest.cpp | 2 | ||||
-rw-r--r-- | storage/src/vespa/storage/bucketdb/abstract_bucket_map.h | 19 |
2 files changed, 9 insertions, 12 deletions
diff --git a/storage/src/tests/bucketdb/lockablemaptest.cpp b/storage/src/tests/bucketdb/lockablemaptest.cpp index 2ac670740c0..727f99fa9f2 100644 --- a/storage/src/tests/bucketdb/lockablemaptest.cpp +++ b/storage/src/tests/bucketdb/lockablemaptest.cpp @@ -781,7 +781,7 @@ TYPED_TEST(LockableMapTest, entry_changes_not_visible_if_write_not_invoked_on_gu TYPED_TEST(LockableMapTest, track_sizes) { TypeParam map; - EXPECT_EQ(56ul, sizeof(typename TypeParam::WrappedEntry)); + EXPECT_EQ(48ul, sizeof(typename TypeParam::WrappedEntry)); } } // storage diff --git a/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h b/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h index 1004a848c5e..7d3798a65a0 100644 --- a/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h +++ b/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h @@ -34,40 +34,37 @@ private: class LockKeeper { public: LockKeeper() noexcept - : _map(nullptr), _key(), _locked(false) {} + : _map(nullptr), _key() {} LockKeeper(AbstractBucketMap& map, key_type key) noexcept - : _map(&map), _key(key), _locked(true) {} + : _map(&map), _key(key) {} LockKeeper(LockKeeper && rhs) noexcept : _map(rhs._map), - _key(rhs._key), - _locked(rhs._locked) + _key(rhs._key) { - rhs._locked = false; + rhs._map = nullptr; } LockKeeper & operator=(LockKeeper && rhs) noexcept { if (&rhs == this) return *this; cleanup(); _map = rhs._map; _key = rhs._key; - _locked = rhs._locked; - rhs._locked = false; + rhs._map = nullptr; return *this; } ~LockKeeper() { cleanup(); } AbstractBucketMap & map() { return *_map; } void unlock() { _map->unlock(_key); - _locked = false; + _map = nullptr; } - bool locked() const noexcept { return _locked; } + bool locked() const noexcept { return _map != nullptr; } const key_type & key() const noexcept { return _key; } private: void cleanup() { - if (_locked) unlock(); + if (_map) unlock(); } AbstractBucketMap * _map; key_type _key; - bool _locked; }; public: |