Skip to content

Commit

Permalink
Actual fix for issue #125
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Jan 31, 2022
1 parent 7c092b7 commit ed229ad
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,20 @@ class parallel_hash_set
// --------------------------------------------------------------------
struct Inner : public Lockable
{
struct Params
{
size_t bucket_cnt;
const hasher& hashfn;
const key_equal& eq;
const allocator_type& alloc;
};

Inner() {}

Inner(Params p) :
set_(p.bucket_cnt, p.hashfn, p.eq, p.alloc)
{}

bool operator==(const Inner& o) const
{
typename Lockable::SharedLocks l(const_cast<Inner &>(*this), const_cast<Inner &>(o));
Expand Down Expand Up @@ -2637,10 +2651,15 @@ class parallel_hash_set
explicit parallel_hash_set(size_t bucket_cnt,
const hasher& hash_param = hasher(),
const key_equal& eq = key_equal(),
const allocator_type& alloc = allocator_type()) {
for (auto& inner : sets_)
inner.set_ = EmbeddedSet(bucket_cnt / N, hash_param, eq, alloc);
}
const allocator_type& alloc = allocator_type()) :
parallel_hash_set(Inner::Params(bucket_cnt, hash_param, eq, alloc),
phmap::make_index_sequence<num_tables>{})
{}

template <std::size_t... i>
parallel_hash_set(Inner::Params p,
phmap::index_sequence<i...>) : sets_{((void)i, p)...}
{}

parallel_hash_set(size_t bucket_cnt,
const hasher& hash_param,
Expand Down

0 comments on commit ed229ad

Please sign in to comment.