Commit 656319d7 authored by Barys Skarabahaty's avatar Barys Skarabahaty Committed by Facebook GitHub Bot

Return actual iterator on assign_if_equal

Summary: There is no sense to return the iterator that points to the outdated node that just was overwritten by `assign_if_equal` call.

Reviewed By: yfeldblum

Differential Revision: D27678357

fbshipit-source-id: f07ce21df6556819f7eb103a623d3f7a46e72072
parent c63e0608
......@@ -670,6 +670,7 @@ class alignas(64) BucketTable {
next->acquire_link(); // defined in hazptr_obj_base_linked
}
prev->store(cur, std::memory_order_release);
it.setNode(cur, buckets, bcount, idx);
g.unlock();
// Release not under lock.
node->release();
......
......@@ -934,7 +934,9 @@ TYPED_TEST_P(ConcurrentHashMapTest, HeterogeneousInsert) {
map.insert("foo", "baz");
EXPECT_TRUE(map.assign(foo, "hello2"));
EXPECT_TRUE(map.assign_if_equal("foo", "hello2", "hello"));
auto mbIt = map.assign_if_equal("foo", "hello2", "hello");
EXPECT_TRUE(mbIt);
EXPECT_EQ(mbIt.value()->second, "hello");
EXPECT_EQ(map[foo], "hello");
auto it = map.find(foo);
map.erase(it);
......
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