Commit f6cbd144 authored by Andrey Malevich's avatar Andrey Malevich Committed by Facebook Github Bot

Back out "[folly] more ConcurrentHashMap deletion tests"

Summary:
Original commit changeset: bee63b3f597d.

Original revision is breaking integration tests by failing with the SIGSEGV in operator++, please check D6993857 for more details.

Reviewed By: anshulverma

Differential Revision: D7051998

fbshipit-source-id: e5cfbb22aee5f5ec9871a9a34bb27eb5b0036d1b
parent 051bd89d
......@@ -444,17 +444,13 @@ class ConcurrentHashMap {
void next() {
while (it_ == parent_->ensureSegment(segment_)->cend() &&
segment_ < parent_->NumShards) {
SegmentT* seg{nullptr};
while (!seg) {
segment_++;
seg = parent_->segments_[segment_].load(std::memory_order_acquire);
if (segment_ < parent_->NumShards) {
if (!seg) {
continue;
}
it_ = seg->cbegin();
segment_++;
auto seg = parent_->segments_[segment_].load(std::memory_order_acquire);
if (segment_ < parent_->NumShards) {
if (!seg) {
continue;
}
break;
it_ = seg->cbegin();
}
}
}
......
......@@ -589,8 +589,6 @@ class alignas(64) ConcurrentHashMapSegment {
// throw if hash or key_eq functions throw.
void erase(Iterator& res, Iterator& pos) {
erase_internal(pos->first, &res);
// Invalidate the iterator.
pos = cend();
}
void clear() {
......
......@@ -594,107 +594,25 @@ TEST(ConcurrentHashMap, RefcountTest) {
}
struct Wrapper {
explicit Wrapper(bool& del_) : del(del_) {}
Wrapper() = default;
~Wrapper() {
del = true;
}
bool& del;
static bool del;
};
TEST(ConcurrentHashMap, Deletion) {
bool del{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
bool Wrapper::del = false;
map.insert(0, std::make_shared<Wrapper>(del));
}
EXPECT_TRUE(del);
}
TEST(ConcurrentHashMap, DeletionWithErase) {
bool del{false};
TEST(ConcurrentHashMap, Deletion) {
EXPECT_FALSE(Wrapper::del);
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>(del));
map.insert(0, std::make_shared<Wrapper>());
map.erase(0);
}
EXPECT_TRUE(del);
}
TEST(ConcurrentHashMap, DeletionWithIterator) {
bool del{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>(del));
auto it = map.find(0);
map.erase(it);
}
EXPECT_TRUE(del);
}
TEST(ConcurrentHashMap, DeletionWithForLoop) {
bool del{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>(del));
for (auto it = map.cbegin(); it != map.cend(); ++it) {
EXPECT_EQ(it->first, 0);
}
}
EXPECT_TRUE(del);
}
TEST(ConcurrentHashMap, DeletionMultiple) {
bool del1{false}, del2{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>(del1));
map.insert(1, std::make_shared<Wrapper>(del2));
}
EXPECT_TRUE(del1);
EXPECT_TRUE(del2);
}
TEST(ConcurrentHashMap, DeletionAssigned) {
bool del1{false}, del2{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>(del1));
map.insert_or_assign(0, std::make_shared<Wrapper>(del2));
}
EXPECT_TRUE(del1);
EXPECT_TRUE(del2);
}
TEST(ConcurrentHashMap, DeletionMultipleMaps) {
bool del1{false}, del2{false};
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map1;
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map2;
map1.insert(0, std::make_shared<Wrapper>(del1));
map2.insert(0, std::make_shared<Wrapper>(del2));
}
EXPECT_TRUE(del1);
EXPECT_TRUE(del2);
EXPECT_TRUE(Wrapper::del);
}
......@@ -702,7 +702,6 @@ FOLLY_ALWAYS_INLINE hazptr_array<M>::~hazptr_array() {
auto count = tc.count();
if ((M <= HAZPTR_TC_SIZE) && (count + M <= HAZPTR_TC_SIZE)) {
for (size_t i = 0; i < M; ++i) {
h[i].reset();
tc[count + i].hprec_ = h[i].hazptr_;
HAZPTR_DEBUG_PRINT(i << " " << &h[i]);
new (&h[i]) hazptr_holder(nullptr);
......
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