From e557babaad421e48a6c36acec1e75fb8c93f383f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 4 Dec 2015 12:07:42 -0800 Subject: [PATCH] Fix the generic implementation of ExternalCommitHelper --- src/impl/generic/external_commit_helper.cpp | 3 +++ src/impl/generic/external_commit_helper.hpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/impl/generic/external_commit_helper.cpp b/src/impl/generic/external_commit_helper.cpp index 66417642..e50e884a 100644 --- a/src/impl/generic/external_commit_helper.cpp +++ b/src/impl/generic/external_commit_helper.cpp @@ -32,7 +32,10 @@ ExternalCommitHelper::ExternalCommitHelper(RealmCoordinator& parent) , m_sg(*m_history, parent.is_in_memory() ? SharedGroup::durability_MemOnly : SharedGroup::durability_Full, parent.get_encryption_key().data()) , m_thread(std::async(std::launch::async, [=] { + m_sg.begin_read(); while (m_sg.wait_for_change()) { + m_sg.end_read(); + m_sg.begin_read(); m_parent.on_change(); } })) diff --git a/src/impl/generic/external_commit_helper.hpp b/src/impl/generic/external_commit_helper.hpp index 3249430e..d056566e 100644 --- a/src/impl/generic/external_commit_helper.hpp +++ b/src/impl/generic/external_commit_helper.hpp @@ -40,12 +40,12 @@ public: private: RealmCoordinator& m_parent; - // The listener thread - std::future m_thread; - // A shared group used to listen for changes std::unique_ptr m_history; SharedGroup m_sg; + + // The listener thread + std::future m_thread; }; } // namespace _impl