allow running all tests at the same path by invalidating all cached realm paths between test runs
This commit is contained in:
parent
b70e5432b7
commit
ad677b7873
|
@ -198,7 +198,9 @@ bool Realm::update_schema(std::unique_ptr<Schema> schema, uint64_t version)
|
|||
auto migration_function = [&](Group*, Schema&) {
|
||||
SharedRealm old_realm(new Realm(old_config));
|
||||
auto updated_realm = shared_from_this();
|
||||
m_config.migration_function(old_realm, updated_realm);
|
||||
if (m_config.migration_function) {
|
||||
m_config.migration_function(old_realm, updated_realm);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -438,6 +440,19 @@ void RealmCache::cache_realm(SharedRealm &realm, std::thread::id thread_id)
|
|||
}
|
||||
}
|
||||
|
||||
void RealmCache::invalidate_all()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
for (auto &path_realms:m_cache) {
|
||||
for (auto &realm_iter:path_realms.second) {
|
||||
if (auto realm = realm_iter.second.lock()) {
|
||||
realm->invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RealmCache::clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
|
|
@ -131,6 +131,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 invalidate_all();
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue