object store fixes for js binding

This commit is contained in:
Ari Lazier 2016-03-03 14:45:44 -08:00
parent 7802a9e976
commit 4923d7d953
6 changed files with 26 additions and 6 deletions

View File

@ -199,6 +199,22 @@ void RealmCoordinator::clear_cache()
} }
} }
void RealmCoordinator::clear_all_caches()
{
std::vector<std::weak_ptr<RealmCoordinator>> to_clear;
{
std::lock_guard<std::mutex> 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() void RealmCoordinator::send_commit_notifications()
{ {
REALM_ASSERT(!m_config.read_only); REALM_ASSERT(!m_config.read_only);

View File

@ -65,7 +65,10 @@ public:
// Should only be called in test code, as continuing to use the previously // Should only be called in test code, as continuing to use the previously
// cached instances will have odd results // cached instances will have odd results
static void clear_cache(); 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 // Explicit constructor/destructor needed for the unique_ptrs to forward-declared types
RealmCoordinator(); RealmCoordinator();
~RealmCoordinator(); ~RealmCoordinator();

View File

@ -19,6 +19,8 @@
#ifndef REALM_OBJECT_SCHEMA_HPP #ifndef REALM_OBJECT_SCHEMA_HPP
#define REALM_OBJECT_SCHEMA_HPP #define REALM_OBJECT_SCHEMA_HPP
#include "property.hpp"
#include <realm/string_data.hpp> #include <realm/string_data.hpp>
#include <string> #include <string>
@ -26,7 +28,6 @@
namespace realm { namespace realm {
class Group; class Group;
struct Property;
class ObjectSchema { class ObjectSchema {
public: public:

View File

@ -19,8 +19,7 @@
#ifndef REALM_OBJECT_STORE_HPP #ifndef REALM_OBJECT_STORE_HPP
#define REALM_OBJECT_STORE_HPP #define REALM_OBJECT_STORE_HPP
#include "object_schema.hpp" #include "schema.hpp"
#include "property.hpp"
#include <functional> #include <functional>

View File

@ -19,7 +19,7 @@
#ifndef REALM_SCHEMA_HPP #ifndef REALM_SCHEMA_HPP
#define REALM_SCHEMA_HPP #define REALM_SCHEMA_HPP
#include "property.hpp" #include "object_schema.hpp"
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -19,6 +19,8 @@
#ifndef REALM_REALM_HPP #ifndef REALM_REALM_HPP
#define REALM_REALM_HPP #define REALM_REALM_HPP
#include "object_store.hpp"
#include <realm/handover_defs.hpp> #include <realm/handover_defs.hpp>
#include <memory> #include <memory>
@ -34,7 +36,6 @@ namespace realm {
class Group; class Group;
class Realm; class Realm;
class RealmDelegate; class RealmDelegate;
class Schema;
class SharedGroup; class SharedGroup;
typedef std::shared_ptr<Realm> SharedRealm; typedef std::shared_ptr<Realm> SharedRealm;
typedef std::weak_ptr<Realm> WeakRealm; typedef std::weak_ptr<Realm> WeakRealm;