From b0843356dc39135ac0fec21e8a2e97cbc325a894 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Wed, 12 Aug 2015 12:02:56 -0700 Subject: [PATCH] clear Realm cache between tests --- shared_realm.cpp | 7 +++++++ shared_realm.hpp | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/shared_realm.cpp b/shared_realm.cpp index 10c09f6c6b..a7269591eb 100644 --- a/shared_realm.cpp +++ b/shared_realm.cpp @@ -395,3 +395,10 @@ void RealmCache::cache_realm(SharedRealm &realm, std::thread::id thread_id) } } +void RealmCache::clear() +{ + std::lock_guard lock(m_mutex); + + m_cache.clear(); +} + diff --git a/shared_realm.hpp b/shared_realm.hpp index e2640386bb..af8b774a92 100644 --- a/shared_realm.hpp +++ b/shared_realm.hpp @@ -117,13 +117,13 @@ namespace realm { Group *m_group; static std::mutex s_init_mutex; - static RealmCache s_global_cache; public: ExternalNotificationFunction m_external_notifier; // FIXME private Group *read_group(); + static RealmCache s_global_cache; }; class RealmCache @@ -133,6 +133,7 @@ namespace realm { SharedRealm get_any_realm(const std::string &path); void remove(const std::string &path, std::thread::id thread_id); void cache_realm(SharedRealm &realm, std::thread::id thread_id = std::this_thread::get_id()); + void clear(); private: std::map> m_cache;