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