diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp index 61c48351584..8bd5ebcaeb5 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "JavaTimerRegistry.h" @@ -90,8 +90,8 @@ JReactInstance::JReactInstance( auto unbufferedRuntimeExecutor = instance_->getUnbufferedRuntimeExecutor(); // Set up the JS and native modules call invokers (for TurboModules) - auto jsInvoker = - std::make_unique(unbufferedRuntimeExecutor); + auto jsInvoker = std::make_unique( + instance_->getRuntimeScheduler()); jsCallInvokerHolder_ = jni::make_global( CallInvokerHolder::newObjectCxxArgs(std::move(jsInvoker))); auto nativeMethodCallInvoker = diff --git a/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.cpp b/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.cpp deleted file mode 100644 index 20519e6a3b4..00000000000 --- a/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "BridgelessJSCallInvoker.h" - -#include - -namespace facebook::react { - -BridgelessJSCallInvoker::BridgelessJSCallInvoker( - RuntimeExecutor runtimeExecutor) - : runtimeExecutor_(std::move(runtimeExecutor)) {} - -void BridgelessJSCallInvoker::invokeAsync(CallFunc&& func) noexcept { - runtimeExecutor_( - [func = std::move(func)](jsi::Runtime& runtime) { func(runtime); }); -} - -void BridgelessJSCallInvoker::invokeSync(CallFunc&& /*func*/) { - // TODO: Implement this method. The TurboModule infra doesn't call invokeSync. - throw std::runtime_error( - "Synchronous native -> JS calls are currently not supported."); -} - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.h b/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.h deleted file mode 100644 index a411c5e8a03..00000000000 --- a/packages/react-native/ReactCommon/react/runtime/BridgelessJSCallInvoker.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include - -namespace facebook::react { - -/** - * A native-to-JS call invoker that uses the RuntimeExecutor. It guarantees that - * any calls from any thread are queued on the right JS thread. - */ -class BridgelessJSCallInvoker : public CallInvoker { - public: - explicit BridgelessJSCallInvoker(RuntimeExecutor runtimeExecutor); - void invokeAsync(CallFunc&& func) noexcept override; - void invokeSync(CallFunc&& func) override; - - private: - RuntimeExecutor runtimeExecutor_; -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 1de5cff31d3..ddeb1e9eff9 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -37,7 +37,7 @@ #import #import #import -#import +#import #import #import @@ -249,7 +249,7 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags) RuntimeExecutor bufferedRuntimeExecutor = _reactInstance->getBufferedRuntimeExecutor(); timerManager->setRuntimeExecutor(bufferedRuntimeExecutor); - auto jsCallInvoker = make_shared(bufferedRuntimeExecutor); + auto jsCallInvoker = make_shared(_reactInstance->getRuntimeScheduler()); RCTBridgeProxy *bridgeProxy = [[RCTBridgeProxy alloc] initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED moduleRegistry:_bridgeModuleDecorator.moduleRegistry