Skip to content

Commit

Permalink
clear Realm cache between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alazier committed Aug 13, 2015
1 parent cb8364c commit b084335
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions shared_realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,10 @@ void RealmCache::cache_realm(SharedRealm &realm, std::thread::id thread_id)
}
}

void RealmCache::clear()
{
std::lock_guard<std::mutex> lock(m_mutex);

m_cache.clear();
}

3 changes: 2 additions & 1 deletion shared_realm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<std::string, std::map<std::thread::id, WeakRealm>> m_cache;
Expand Down

0 comments on commit b084335

Please sign in to comment.