Summary:
While the returned iterators are always 'valid' and can be read and iterated from,
they may still be concurrently erased from the map. Current erase(iter) has DCHECKS that assert we can always
erase an iterator, but it may have already been removed.
Reviewed By: davidtgoldblatt
Differential Revision:
D6221382
fbshipit-source-id:
70b21f53e2fc3daa126df4fb60bc5d3ecb253c71
node->release();
return 1;
}
- DCHECK(!iter);
return 0;
}
// This is a small departure from standard stl containers: erase may
// throw if hash or key_eq functions throw.
void erase(Iterator& res, Iterator& pos) {
- auto cnt = erase_internal(pos->first, &res);
- DCHECK(cnt == 1);
+ erase_internal(pos->first, &res);
}
void clear() {
EXPECT_EQ(count, 2);
}
+TEST(ConcurrentHashMap, EraseTest) {
+ ConcurrentHashMap<uint64_t, uint64_t> foomap(3);
+ foomap.insert(1, 0);
+ auto f1 = foomap.find(1);
+ EXPECT_EQ(1, foomap.erase(1));
+ foomap.erase(f1);
+}
+
// TODO: hazptrs must support DeterministicSchedule
#define Atom std::atomic // DeterministicAtomic