Commit 4c291582 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Fix ObserverManager::waitForAllUpdates() to not deadlock

Summary: Make sure waitForAllUpdates returns if there are no updates in flight.

Reviewed By: yfeldblum

Differential Revision: D13165909

fbshipit-source-id: d48c1f3b7df451fed4aec54ab6d9c9cedb1d7470
parent 30af28c6
...@@ -118,11 +118,9 @@ class ObserverManager::NextQueue { ...@@ -118,11 +118,9 @@ class ObserverManager::NextQueue {
std::vector<Core::Ptr> cores; std::vector<Core::Ptr> cores;
{ {
auto queueCore = queueCoreWeak.lock(); if (auto queueCore = queueCoreWeak.lock()) {
if (!queueCore) { cores.emplace_back(std::move(queueCore));
continue;
} }
cores.emplace_back(std::move(queueCore));
} }
{ {
......
...@@ -377,4 +377,6 @@ TEST(Observer, WaitForAllUpdates) { ...@@ -377,4 +377,6 @@ TEST(Observer, WaitForAllUpdates) {
folly::observer_detail::ObserverManager::waitForAllUpdates(); folly::observer_detail::ObserverManager::waitForAllUpdates();
EXPECT_EQ(43, **observer); EXPECT_EQ(43, **observer);
folly::observer_detail::ObserverManager::waitForAllUpdates();
} }
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