diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-02-18 16:38:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-18 16:38:15 +0100 |
commit | a0806ea0ee6941e31538033bfb2bc6c8421beddb (patch) | |
tree | 2736fabcb365e6e0c4b54985735cd9f0f2a0e5b4 | |
parent | 9e2e9a2642fd9a5f073e098c86cfbfcbf80e75a9 (diff) | |
parent | 4d353d64999d131a7d5cdc831777666ac31c2057 (diff) |
Merge pull request #21280 from vespa-engine/vekterli/acquire-semantics-on-sharded-hash-map-reads
Form a full release/acquire pair on lock-free hash map shards
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp index 019b98a53dd..2ae22084472 100644 --- a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp +++ b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp @@ -88,7 +88,7 @@ ShardedHashMap::KvType* ShardedHashMap::find(const EntryComparator& comp, EntryRef key_ref) { ShardedHashComparator shardedComp(comp, key_ref, num_shards); - auto map = _maps[shardedComp.shard_idx()].load(std::memory_order_relaxed); + auto map = _maps[shardedComp.shard_idx()].load(std::memory_order_acquire); if (map == nullptr) { return nullptr; } @@ -99,7 +99,7 @@ const ShardedHashMap::KvType* ShardedHashMap::find(const EntryComparator& comp, EntryRef key_ref) const { ShardedHashComparator shardedComp(comp, key_ref, num_shards); - auto map = _maps[shardedComp.shard_idx()].load(std::memory_order_relaxed); + auto map = _maps[shardedComp.shard_idx()].load(std::memory_order_acquire); if (map == nullptr) { return nullptr; } @@ -135,7 +135,7 @@ ShardedHashMap::size() const noexcept { size_t result = 0; for (size_t i = 0; i < num_shards; ++i) { - auto map = _maps[i].load(std::memory_order_relaxed); + auto map = _maps[i].load(std::memory_order_acquire); if (map != nullptr) { result += map->size(); } @@ -148,7 +148,7 @@ ShardedHashMap::get_memory_usage() const { MemoryUsage memory_usage(sizeof(ShardedHashMap), sizeof(ShardedHashMap), 0, 0); for (size_t i = 0; i < num_shards; ++i) { - auto map = _maps[i].load(std::memory_order_relaxed); + auto map = _maps[i].load(std::memory_order_acquire); if (map != nullptr) { memory_usage.merge(map->get_memory_usage()); } @@ -163,7 +163,7 @@ void ShardedHashMap::foreach_key(std::function<void(EntryRef)> callback) const { for (size_t i = 0; i < num_shards; ++i) { - auto map = _maps[i].load(std::memory_order_relaxed); + auto map = _maps[i].load(std::memory_order_acquire); if (map != nullptr) { map->foreach_key(callback); } @@ -211,7 +211,7 @@ void ShardedHashMap::foreach_value(std::function<void(const std::vector<EntryRef>&)> callback, const EntryRefFilter& filter) { for (size_t i = 0; i < num_shards; ++i) { - auto map = _maps[i].load(std::memory_order_relaxed); + auto map = _maps[i].load(std::memory_order_acquire); if (map != nullptr) { map->foreach_value(callback, filter); } |