Summary: Because these `atomic<int>` are referenced in the destructor of the `ReadMostlyMainPtr`, they must be declared before it, otherwise they are destroyed before it i.
Reviewed By: yfeldblum
Differential Revision:
D4854964
fbshipit-source-id:
625a8f890bba166b682ca13558f8bcde86edcc75
}
TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
}
TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
+ std::atomic<int> cnt1{0};
+ std::atomic<int> cnt2{0};
+
ReadMostlyMainPtr<TestObject> ptr;
// Store 1.
ReadMostlyMainPtr<TestObject> ptr;
// Store 1.
- std::atomic<int> cnt1{0};
ptr.reset(folly::make_unique<TestObject>(1, cnt1));
Coordinator c;
ptr.reset(folly::make_unique<TestObject>(1, cnt1));
Coordinator c;
EXPECT_EQ(1, cnt1.load());
// Store 2 and check that 1 is destroyed.
EXPECT_EQ(1, cnt1.load());
// Store 2 and check that 1 is destroyed.
- std::atomic<int> cnt2{0};
ptr.reset(folly::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(0, cnt1.load());
ptr.reset(folly::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(0, cnt1.load());