Skip to content

Commit

Permalink
Add access to the slot in the lazy constructor. There is a specific u…
Browse files Browse the repository at this point in the history
…se 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.
  • Loading branch information
bpmckinnon authored Nov 29, 2023
1 parent 9248dcf commit 7556c95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,10 @@ class raw_hash_set
friend class raw_hash_set;

public:
slot_type* slot() const {
return *slot_;
}

template <class... Args>
void operator()(Args&&... args) const {
assert(*slot_);
Expand Down Expand Up @@ -3247,7 +3251,7 @@ class parallel_hash_set
set.lazy_emplace_at(offset, std::forward<F>(f));
set.set_ctrl(offset, H2(hashval));
}
return iterator_at(offset);
return make_iterator(&inner, set.iterator_at(offset));
}

template <class K = key_type, class F>
Expand Down
2 changes: 1 addition & 1 deletion parallel_hashmap/phmap_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -4882,8 +4882,8 @@ class LockableBaseImpl

private:
mutex_type *m_;
bool locked_shared_;
bool locked_;
bool locked_shared_;
};

// ----------------------------------------------------
Expand Down

0 comments on commit 7556c95

Please sign in to comment.