Switch to using object store's master branch (#748)

* Switch to using object store's master branch.

* Switch to caching Realm instances per JavaScript execution context.
This commit is contained in:
Mark Rowe 2016-12-28 08:28:44 -08:00 committed by Kristian Dupont
parent 914866beff
commit d8e13bc7bb
9 changed files with 26 additions and 22 deletions

2
.gitmodules vendored
View File

@ -7,4 +7,4 @@
[submodule "src/object-store"] [submodule "src/object-store"]
path = src/object-store path = src/object-store
url = https://github.com/realm/realm-object-store.git url = https://github.com/realm/realm-object-store.git
branch = js branch = master

View File

@ -63,7 +63,6 @@
"src/object-store/src/parser/parser.cpp", "src/object-store/src/parser/parser.cpp",
"src/object-store/src/parser/query_builder.cpp", "src/object-store/src/parser/query_builder.cpp",
"src/object-store/src/util/format.cpp", "src/object-store/src/util/format.cpp",
"src/object-store/src/util/thread_id.cpp",
], ],
"conditions": [ "conditions": [
["OS=='linux'", { ["OS=='linux'", {

View File

@ -41,7 +41,6 @@ LOCAL_SRC_FILES += src/object-store/src/impl/epoll/external_commit_helper.cpp
LOCAL_SRC_FILES += src/object-store/src/parser/parser.cpp LOCAL_SRC_FILES += src/object-store/src/parser/parser.cpp
LOCAL_SRC_FILES += src/object-store/src/parser/query_builder.cpp LOCAL_SRC_FILES += src/object-store/src/parser/query_builder.cpp
LOCAL_SRC_FILES += src/object-store/src/util/format.cpp LOCAL_SRC_FILES += src/object-store/src/util/format.cpp
LOCAL_SRC_FILES += src/object-store/src/util/thread_id.cpp
LOCAL_SRC_FILES += src/object-store/src/collection_notifications.cpp LOCAL_SRC_FILES += src/object-store/src/collection_notifications.cpp
LOCAL_SRC_FILES += src/object-store/src/index_set.cpp LOCAL_SRC_FILES += src/object-store/src/index_set.cpp
LOCAL_SRC_FILES += src/object-store/src/list.cpp LOCAL_SRC_FILES += src/object-store/src/list.cpp

View File

@ -13,7 +13,6 @@
02022A671DA47BD7000F0C4F /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A611DA47B8B000F0C4F /* parser.cpp */; }; 02022A671DA47BD7000F0C4F /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A611DA47B8B000F0C4F /* parser.cpp */; };
02022A681DA47BD7000F0C4F /* query_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A631DA47B8B000F0C4F /* query_builder.cpp */; }; 02022A681DA47BD7000F0C4F /* query_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A631DA47B8B000F0C4F /* query_builder.cpp */; };
02022A7C1DA47EC8000F0C4F /* format.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A731DA47EC8000F0C4F /* format.cpp */; }; 02022A7C1DA47EC8000F0C4F /* format.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A731DA47EC8000F0C4F /* format.cpp */; };
02022A7D1DA47EC8000F0C4F /* thread_id.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02022A791DA47EC8000F0C4F /* thread_id.cpp */; };
02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */; }; 02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */; };
02414B881CE68CA200A8669F /* dates-v5.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02414B871CE68CA200A8669F /* dates-v5.realm */; }; 02414B881CE68CA200A8669F /* dates-v5.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02414B871CE68CA200A8669F /* dates-v5.realm */; };
02414BA51CE6ABCF00A8669F /* collection_change_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02414B991CE6AAEF00A8669F /* collection_change_builder.cpp */; }; 02414BA51CE6ABCF00A8669F /* collection_change_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02414B991CE6AAEF00A8669F /* collection_change_builder.cpp */; };
@ -97,9 +96,6 @@
02022A741DA47EC8000F0C4F /* format.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = format.hpp; sourceTree = "<group>"; }; 02022A741DA47EC8000F0C4F /* format.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = format.hpp; sourceTree = "<group>"; };
02022A761DA47EC8000F0C4F /* event_loop_signal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = event_loop_signal.hpp; sourceTree = "<group>"; }; 02022A761DA47EC8000F0C4F /* event_loop_signal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = event_loop_signal.hpp; sourceTree = "<group>"; };
02022A781DA47EC8000F0C4F /* event_loop_signal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = event_loop_signal.hpp; sourceTree = "<group>"; }; 02022A781DA47EC8000F0C4F /* event_loop_signal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = event_loop_signal.hpp; sourceTree = "<group>"; };
02022A791DA47EC8000F0C4F /* thread_id.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = thread_id.cpp; sourceTree = "<group>"; };
02022A7A1DA47EC8000F0C4F /* thread_id.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = thread_id.hpp; sourceTree = "<group>"; };
02022A7B1DA47EC8000F0C4F /* thread_local.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = thread_local.hpp; sourceTree = "<group>"; };
02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmJSCoreTests.m; path = ios/RealmJSCoreTests.m; sourceTree = "<group>"; }; 02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmJSCoreTests.m; path = ios/RealmJSCoreTests.m; sourceTree = "<group>"; };
02414B871CE68CA200A8669F /* dates-v5.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v5.realm"; sourceTree = "<group>"; }; 02414B871CE68CA200A8669F /* dates-v5.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v5.realm"; sourceTree = "<group>"; };
02414B961CE6AADD00A8669F /* collection_notifications.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = collection_notifications.cpp; path = src/collection_notifications.cpp; sourceTree = "<group>"; }; 02414B961CE6AADD00A8669F /* collection_notifications.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = collection_notifications.cpp; path = src/collection_notifications.cpp; sourceTree = "<group>"; };
@ -290,9 +286,6 @@
02022A741DA47EC8000F0C4F /* format.hpp */, 02022A741DA47EC8000F0C4F /* format.hpp */,
02022A751DA47EC8000F0C4F /* generic */, 02022A751DA47EC8000F0C4F /* generic */,
02022A771DA47EC8000F0C4F /* node */, 02022A771DA47EC8000F0C4F /* node */,
02022A791DA47EC8000F0C4F /* thread_id.cpp */,
02022A7A1DA47EC8000F0C4F /* thread_id.hpp */,
02022A7B1DA47EC8000F0C4F /* thread_local.hpp */,
); );
name = util; name = util;
path = src/util; path = src/util;
@ -853,7 +846,6 @@
02E315D21DB80DF200555337 /* sync_file.cpp in Sources */, 02E315D21DB80DF200555337 /* sync_file.cpp in Sources */,
02F59EC21C88F17D007F774C /* object_store.cpp in Sources */, 02F59EC21C88F17D007F774C /* object_store.cpp in Sources */,
02022A7C1DA47EC8000F0C4F /* format.cpp in Sources */, 02022A7C1DA47EC8000F0C4F /* format.cpp in Sources */,
02022A7D1DA47EC8000F0C4F /* thread_id.cpp in Sources */,
02E315CB1DB80DDD00555337 /* sync_user.cpp in Sources */, 02E315CB1DB80DDD00555337 /* sync_user.cpp in Sources */,
02E315D31DB80DF200555337 /* sync_metadata.cpp in Sources */, 02E315D31DB80DF200555337 /* sync_metadata.cpp in Sources */,
02F59EC11C88F17D007F774C /* object_schema.cpp in Sources */, 02F59EC11C88F17D007F774C /* object_schema.cpp in Sources */,

View File

@ -405,18 +405,17 @@ void RealmClass<T>::constructor(ContextType ctx, ObjectType this_object, size_t
config.path = normalize_path(config.path); config.path = normalize_path(config.path);
ensure_directory_exists_for_file(config.path); ensure_directory_exists_for_file(config.path);
config.execution_context = reinterpret_cast<AbstractExecutionContextID>(Context<T>::get_execution_context_id(ctx));
SharedRealm realm = realm::Realm::get_shared_realm(config); SharedRealm realm = realm::Realm::get_shared_realm(config);
GlobalContextType global_context = Context<T>::get_global_context(ctx); GlobalContextType global_context = Context<T>::get_global_context(ctx);
BindingContext *binding_context = realm->m_binding_context.get(); if (!realm->m_binding_context) {
RealmDelegate<T> *js_binding_context = dynamic_cast<RealmDelegate<T> *>(binding_context); realm->m_binding_context.reset(new RealmDelegate<T>(realm, global_context));
}
if (!binding_context) { RealmDelegate<T> *js_binding_context = dynamic_cast<RealmDelegate<T> *>(realm->m_binding_context.get());
js_binding_context = new RealmDelegate<T>(realm, global_context); REALM_ASSERT(js_binding_context);
realm->m_binding_context.reset(js_binding_context); REALM_ASSERT(js_binding_context->m_context == global_context);
}
else if (!js_binding_context || js_binding_context->m_context != global_context) {
throw std::runtime_error("Realm is already open in another context on this thread: " + config.path);
}
// If a new schema was provided, then use its defaults and constructors. // If a new schema was provided, then use its defaults and constructors.
if (schema_updated) { if (schema_updated) {

View File

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "execution_context_id.hpp"
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
@ -66,6 +68,7 @@ struct Context {
using GlobalContextType = typename T::GlobalContext; using GlobalContextType = typename T::GlobalContext;
static GlobalContextType get_global_context(ContextType); static GlobalContextType get_global_context(ContextType);
static AbstractExecutionContextID get_execution_context_id(ContextType);
}; };
template<typename T> template<typename T>

View File

@ -28,5 +28,11 @@ inline JSGlobalContextRef jsc::Context::get_global_context(JSContextRef ctx) {
return JSContextGetGlobalContext(ctx); return JSContextGetGlobalContext(ctx);
} }
template<>
inline AbstractExecutionContextID jsc::Context::get_execution_context_id(JSContextRef ctx)
{
return reinterpret_cast<AbstractExecutionContextID>(get_global_context(ctx));
}
} // js } // js
} // realm } // realm

View File

@ -28,5 +28,11 @@ inline v8::Local<v8::Context> node::Context::get_global_context(v8::Isolate* iso
return isolate->GetCurrentContext(); return isolate->GetCurrentContext();
} }
template<>
inline AbstractExecutionContextID node::Context::get_execution_context_id(v8::Isolate* isolate)
{
return reinterpret_cast<AbstractExecutionContextID>(isolate);
}
} // js } // js
} // realm } // realm

@ -1 +1 @@
Subproject commit 5ba86e730071733997a9275d19dab801e1f3b851 Subproject commit c25684764924815c1decc1fe9a9f7d4b64ed7bde