From 4923d7d953be3a04393953f4e3593d74acf0a768 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Thu, 3 Mar 2016 14:45:44 -0800 Subject: [PATCH] object store fixes for js binding --- src/impl/realm_coordinator.cpp | 16 ++++++++++++++++ src/impl/realm_coordinator.hpp | 5 ++++- src/object_schema.hpp | 3 ++- src/object_store.hpp | 3 +-- src/schema.hpp | 2 +- src/shared_realm.hpp | 3 ++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/impl/realm_coordinator.cpp b/src/impl/realm_coordinator.cpp index b9ae3e98..3f587675 100644 --- a/src/impl/realm_coordinator.cpp +++ b/src/impl/realm_coordinator.cpp @@ -199,6 +199,22 @@ void RealmCoordinator::clear_cache() } } +void RealmCoordinator::clear_all_caches() +{ + std::vector> to_clear; + { + std::lock_guard lock(s_coordinator_mutex); + for (auto iter : s_coordinators_per_path) { + to_clear.push_back(iter.second); + } + } + for (auto weak_coordinator : to_clear) { + if (auto coordinator = weak_coordinator.lock()) { + coordinator->clear_cache(); + } + } +} + void RealmCoordinator::send_commit_notifications() { REALM_ASSERT(!m_config.read_only); diff --git a/src/impl/realm_coordinator.hpp b/src/impl/realm_coordinator.hpp index 3cc60a8b..54aa9a41 100644 --- a/src/impl/realm_coordinator.hpp +++ b/src/impl/realm_coordinator.hpp @@ -65,7 +65,10 @@ public: // Should only be called in test code, as continuing to use the previously // cached instances will have odd results static void clear_cache(); - + + // Clears all caches on existing coordinators + static void clear_all_caches(); + // Explicit constructor/destructor needed for the unique_ptrs to forward-declared types RealmCoordinator(); ~RealmCoordinator(); diff --git a/src/object_schema.hpp b/src/object_schema.hpp index 10a2e555..058b83ff 100644 --- a/src/object_schema.hpp +++ b/src/object_schema.hpp @@ -19,6 +19,8 @@ #ifndef REALM_OBJECT_SCHEMA_HPP #define REALM_OBJECT_SCHEMA_HPP +#include "property.hpp" + #include #include @@ -26,7 +28,6 @@ namespace realm { class Group; - struct Property; class ObjectSchema { public: diff --git a/src/object_store.hpp b/src/object_store.hpp index d9104187..d762674b 100644 --- a/src/object_store.hpp +++ b/src/object_store.hpp @@ -19,8 +19,7 @@ #ifndef REALM_OBJECT_STORE_HPP #define REALM_OBJECT_STORE_HPP -#include "object_schema.hpp" -#include "property.hpp" +#include "schema.hpp" #include diff --git a/src/schema.hpp b/src/schema.hpp index 044433f0..9e86efa2 100644 --- a/src/schema.hpp +++ b/src/schema.hpp @@ -19,7 +19,7 @@ #ifndef REALM_SCHEMA_HPP #define REALM_SCHEMA_HPP -#include "property.hpp" +#include "object_schema.hpp" #include #include diff --git a/src/shared_realm.hpp b/src/shared_realm.hpp index 6c249aa1..32fbad98 100644 --- a/src/shared_realm.hpp +++ b/src/shared_realm.hpp @@ -19,6 +19,8 @@ #ifndef REALM_REALM_HPP #define REALM_REALM_HPP +#include "object_store.hpp" + #include #include @@ -34,7 +36,6 @@ namespace realm { class Group; class Realm; class RealmDelegate; - class Schema; class SharedGroup; typedef std::shared_ptr SharedRealm; typedef std::weak_ptr WeakRealm;