mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Merge JSCallInvoker and BridgelessJSCallInvoker (#36965)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36965 Changelog: [Internal] These implementations are identical and can be merged Reviewed By: javache Differential Revision: D45101259 fbshipit-source-id: af7b2e0288f0cae44ae183a639a9d10e58887fc2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
50553f4e81
commit
ef2951ea0c
-25
@@ -1,25 +0,0 @@
|
||||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class BridgelessJSCallInvoker : public CallInvoker {
|
||||
public:
|
||||
explicit BridgelessJSCallInvoker(RuntimeExecutor runtimeExecutor);
|
||||
void invokeAsync(std::function<void()> &&func) override;
|
||||
void invokeSync(std::function<void()> &&func) override;
|
||||
|
||||
private:
|
||||
RuntimeExecutor runtimeExecutor_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
+7
-2
@@ -1,4 +1,9 @@
|
||||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
|
||||
/*
|
||||
* 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 "JReactInstance.h"
|
||||
|
||||
@@ -14,11 +19,11 @@
|
||||
#include <jni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <jsireact/JSIExecutor.h>
|
||||
#include <react/bridgeless/BridgelessJSCallInvoker.h>
|
||||
#include <react/common/mapbuffer/JReadableMapBuffer.h>
|
||||
#include <react/jni/JRuntimeExecutor.h>
|
||||
#include <react/jni/JSLogging.h>
|
||||
#include <react/renderer/mapbuffer/MapBuffer.h>
|
||||
#include "BridgelessJSCallInvoker.h"
|
||||
#include "BridgelessNativeCallInvoker.h"
|
||||
#include "JavaTimerRegistry.h"
|
||||
|
||||
|
||||
+10
-8
@@ -1,12 +1,15 @@
|
||||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
|
||||
/*
|
||||
* 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 <exception>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
namespace facebook::react {
|
||||
|
||||
BridgelessJSCallInvoker::BridgelessJSCallInvoker(
|
||||
RuntimeExecutor runtimeExecutor)
|
||||
@@ -17,10 +20,9 @@ void BridgelessJSCallInvoker::invokeAsync(std::function<void()> &&func) {
|
||||
}
|
||||
|
||||
void BridgelessJSCallInvoker::invokeSync(std::function<void()> &&func) {
|
||||
// TODO: Replace JS Callinvoker with RuntimeExecutor.
|
||||
// TODO: Implement this method. The TurboModule infra doesn't call invokeSync.
|
||||
throw std::runtime_error(
|
||||
"Synchronous native -> JS calls are currently not supported.");
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
} // namespace facebook::react
|
||||
+5
-5
@@ -7,17 +7,17 @@
|
||||
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <functional>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/**
|
||||
* A native-to-JS call invoker that uses the RuntimeExecutor. Inspired by
|
||||
* BridgeJSCallInvoker. It guarantees that any calls from any thread are queued
|
||||
* on the right JS thread.
|
||||
* 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 JSCallInvoker : public CallInvoker {
|
||||
class BridgelessJSCallInvoker : public CallInvoker {
|
||||
public:
|
||||
JSCallInvoker(RuntimeExecutor runtimeExecutor);
|
||||
explicit BridgelessJSCallInvoker(RuntimeExecutor runtimeExecutor);
|
||||
void invokeAsync(std::function<void()> &&func) override;
|
||||
void invokeSync(std::function<void()> &&func) override;
|
||||
|
||||
@@ -1,23 +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 "JSCallInvoker.h"
|
||||
|
||||
namespace facebook ::react {
|
||||
|
||||
JSCallInvoker::JSCallInvoker(RuntimeExecutor runtimeExecutor)
|
||||
: runtimeExecutor_(runtimeExecutor) {}
|
||||
|
||||
void JSCallInvoker::invokeAsync(std::function<void()> &&func) {
|
||||
runtimeExecutor_([func = std::move(func)](jsi::Runtime &runtime) { func(); });
|
||||
}
|
||||
|
||||
void JSCallInvoker::invokeSync(std::function<void()> &&func) {
|
||||
// TODO: Implement this method. The TurboModule infra doesn't call invokeSync.
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
Reference in New Issue
Block a user