Commit ac3169a8 authored by Nick Gibson's avatar Nick Gibson Committed by Facebook Github Bot

ConcurrentHashMap Deletion Test

Summary: Add hazptr_cleanup to ConcurrentHashMap destructor & add a test to ensure deletion is working.

Reviewed By: djwatson

Differential Revision: D6951359

fbshipit-source-id: 277c304a0e5073605010b14764d05a27e6e10b2d
parent 8635022f
...@@ -158,6 +158,7 @@ class ConcurrentHashMap { ...@@ -158,6 +158,7 @@ class ConcurrentHashMap {
Allocator().deallocate((uint8_t*)seg, sizeof(SegmentT)); Allocator().deallocate((uint8_t*)seg, sizeof(SegmentT));
} }
} }
folly::hazptr::hazptr_cleanup(folly::hazptr::default_hazptr_domain());
} }
bool empty() const noexcept { bool empty() const noexcept {
......
...@@ -569,3 +569,27 @@ TEST(ConcurrentHashMap, RefcountTest) { ...@@ -569,3 +569,27 @@ TEST(ConcurrentHashMap, RefcountTest) {
foomap.insert_or_assign(1, i); foomap.insert_or_assign(1, i);
} }
} }
struct Wrapper {
Wrapper() = default;
~Wrapper() {
del = true;
}
static bool del;
};
bool Wrapper::del = false;
TEST(ConcurrentHashMap, Deletion) {
EXPECT_FALSE(Wrapper::del);
{
ConcurrentHashMap<int, std::shared_ptr<Wrapper>> map;
map.insert(0, std::make_shared<Wrapper>());
map.erase(0);
}
EXPECT_TRUE(Wrapper::del);
}
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