diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsJavaNetworkTransport.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsJavaNetworkTransport.cpp index 4dbd46d766..ce83bb31c3 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsJavaNetworkTransport.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsJavaNetworkTransport.cpp @@ -34,7 +34,7 @@ JNIEXPORT void JNICALL Java_io_realm_internal_objectstore_OsJavaNetworkTransport jlong j_completion_block_ptr) { try { - auto& completion_block = *reinterpret_cast*>(j_completion_block_ptr); + util::UniqueFunction &completion_block = *reinterpret_cast*>(j_completion_block_ptr); // Read response static const JavaClass& response_class(JavaClassGlobalDef::network_transport_response_class()); diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSubscriptionSet.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSubscriptionSet.cpp index 4268bcd1f8..cad9c2640c 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSubscriptionSet.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSubscriptionSet.cpp @@ -74,7 +74,7 @@ JNIEXPORT jbyte JNICALL Java_io_realm_internal_objectstore_OsSubscriptionSet_nat return io_realm_internal_objectstore_OsSubscriptionSet_STATE_VALUE_COMPLETE; case sync::SubscriptionSet::State::Error: return io_realm_internal_objectstore_OsSubscriptionSet_STATE_VALUE_ERROR; - case sync::SubscriptionSet::State::Superceded: + case sync::SubscriptionSet::State::Superseded: return io_realm_internal_objectstore_OsSubscriptionSet_STATE_VALUE_SUPERSEDED; } } diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp index c27de9d41d..1fac6f13dc 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp @@ -45,14 +45,13 @@ Java_io_realm_mongodb_FunctionsImpl_nativeCallFunction(JNIEnv* env, jclass , jlo auto user = *reinterpret_cast*>(j_user_ptr); std::function, util::Optional)> callback = JavaNetworkTransport::create_result_callback(env, j_callback, success_mapper); - - auto handler = [callback](util::Optional error, util::Optional response) { + util::UniqueFunction&&, util::Optional)> handler = [callback](const util::Optional& response, const util::Optional& error) { callback(response, error); }; JStringAccessor name(env, j_name); BsonArray args(JniBsonProtocol::parse_checked(env, j_args_json, Bson::Type::Array, "BSON argument must be an BsonArray")); - app->call_function(user, name, args, handler); + app->call_function(user, name, args, std::move(handler)); } CATCH_STD() } diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp index 88f567c77b..1de42c5c66 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp @@ -289,7 +289,7 @@ JNIEXPORT jlong JNICALL Java_io_realm_mongodb_sync_SyncSession_nativeAddConnecti throw std::runtime_error("An unexpected Error was thrown from Java. See LogCat"); } }; - uint64_t token = session->register_connection_change_callback(callback); + uint64_t token = session->register_connection_change_callback(std::move(callback)); return static_cast(token); } CATCH_STD() diff --git a/realm/realm-library/src/main/cpp/java_network_transport.hpp b/realm/realm-library/src/main/cpp/java_network_transport.hpp index 23afa4fbed..c903d0e7a4 100644 --- a/realm/realm-library/src/main/cpp/java_network_transport.hpp +++ b/realm/realm-library/src/main/cpp/java_network_transport.hpp @@ -42,8 +42,7 @@ struct JavaNetworkTransport : public app::GenericNetworkTransport { REALM_ASSERT_RELEASE_EX(m_send_request_method != nullptr, method_name, signature); } - void send_request_to_server(const app::Request request, std::function completionBlock) - { + void send_request_to_server(Request &&request, util::UniqueFunction &&completionBlock) override { JNIEnv* env = JniUtils::get_env(true); // Setup method @@ -82,7 +81,7 @@ struct JavaNetworkTransport : public app::GenericNetworkTransport { static_cast(request.timeout_ms), request_headers, jbody, - new std::function(std::move(completionBlock)) + new util::UniqueFunction(std::move(completionBlock)) ); env->DeleteLocalRef(jmethod); env->DeleteLocalRef(jurl); diff --git a/realm/realm-library/src/main/cpp/realm-core b/realm/realm-library/src/main/cpp/realm-core index 733f12702d..3ff90552f8 160000 --- a/realm/realm-library/src/main/cpp/realm-core +++ b/realm/realm-library/src/main/cpp/realm-core @@ -1 +1 @@ -Subproject commit 733f12702d16ab0d0c7fea0831a2aee5ca5c26db +Subproject commit 3ff90552f81138a5d4339bf0572abd51144a4bb0