Reduce s_init_mutex's scope

This commit is contained in:
Thomas Goyne 2015-08-24 13:14:59 -07:00 committed by Ari Lazier
parent 292d9cf820
commit 938668904e
2 changed files with 2 additions and 4 deletions

View File

@ -23,11 +23,11 @@
#include <realm/lang_bind_helper.hpp>
#include <memory>
#include <mutex>
using namespace realm;
RealmCache Realm::s_global_cache;
std::mutex Realm::s_init_mutex;
Realm::Config::Config(const Config& c) : path(c.path), read_only(c.read_only), in_memory(c.in_memory), schema_version(c.schema_version), migration_function(c.migration_function)
{
@ -108,6 +108,7 @@ SharedRealm Realm::get_shared_realm(Config &config)
realm = SharedRealm(new Realm(config));
// we want to ensure we are only initializing a single realm at a time
static std::mutex s_init_mutex;
std::lock_guard<std::mutex> lock(s_init_mutex);
uint64_t old_version = ObjectStore::get_schema_version(realm->read_group());

View File

@ -22,7 +22,6 @@
#include <memory>
#include <thread>
#include <vector>
#include <mutex>
#include <set>
#include <map>
@ -117,8 +116,6 @@ namespace realm {
Group *m_group;
static std::mutex s_init_mutex;
public:
ExternalNotificationFunction m_external_notifier;