Skip to content

Commit

Permalink
Reduce s_init_mutex's scope
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Sep 9, 2015
1 parent b4f856b commit 348f4a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion shared_realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 0 additions & 3 deletions shared_realm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <memory>
#include <thread>
#include <vector>
#include <mutex>
#include <set>
#include <map>

Expand Down Expand Up @@ -117,8 +116,6 @@ namespace realm {

Group *m_group;

static std::mutex s_init_mutex;

public:
ExternalNotificationFunction m_external_notifier;

Expand Down

0 comments on commit 348f4a7

Please sign in to comment.