Commit 897877b8 authored by Dave Watson's avatar Dave Watson Committed by Facebook Github Bot

Remove incorrect DCHECKS

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
parent a77fea17
......@@ -543,7 +543,6 @@ class FOLLY_ALIGNED(64) ConcurrentHashMapSegment {
node->release();
return 1;
}
DCHECK(!iter);
return 0;
}
......@@ -555,8 +554,7 @@ class FOLLY_ALIGNED(64) ConcurrentHashMapSegment {
// 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() {
......
......@@ -208,6 +208,14 @@ TEST(ConcurrentHashMap, MapIterateTest) {
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment