From 7556c955d48e396535dba54069c7fb4bd35a62b5 Mon Sep 17 00:00:00 2001 From: bpmckinnon Date: Wed, 29 Nov 2023 08:15:02 -0600 Subject: [PATCH] Add access to the slot in the lazy constructor. There is a specific use case where I want to cache a pointer to the newly created lazy object. If the capacity of the map does not change between the first and second call of my function, then I use the pointer instead of repeating the lookup. (#219) Fixed an initialization order issue in ReadWriteLock Fix the return value of lazy_emplace and lazy_emplace_with_hash. --- parallel_hashmap/phmap.h | 6 +++++- parallel_hashmap/phmap_base.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 52d677e..4b1e95b 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -1506,6 +1506,10 @@ class raw_hash_set friend class raw_hash_set; public: + slot_type* slot() const { + return *slot_; + } + template void operator()(Args&&... args) const { assert(*slot_); @@ -3247,7 +3251,7 @@ class parallel_hash_set set.lazy_emplace_at(offset, std::forward(f)); set.set_ctrl(offset, H2(hashval)); } - return iterator_at(offset); + return make_iterator(&inner, set.iterator_at(offset)); } template diff --git a/parallel_hashmap/phmap_base.h b/parallel_hashmap/phmap_base.h index db4f767..7f0e26a 100644 --- a/parallel_hashmap/phmap_base.h +++ b/parallel_hashmap/phmap_base.h @@ -4882,8 +4882,8 @@ class LockableBaseImpl private: mutex_type *m_; - bool locked_shared_; bool locked_; + bool locked_shared_; }; // ----------------------------------------------------