mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor: Move RuntimeExecutor into Instance.cpp
Summary: RuntimeExecutor is currently declared inside NativeToJsBridge. It doesn't need to be: Instance.cpp can use NativeToJsBridge::runOnExecutorQueue to schedule work on the JS Thread. So, this diff moves RuntimeExecutor out of NativeToJsBridge into Instance.cpp. Now, both the JS CallInvoker and the RuntimeExecutor are declared in the same file. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D27975840 fbshipit-source-id: aa06f479fa24bb7a15bfd21712df5414a183266c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c68c55469f
commit
db3625a3b0
@@ -340,26 +340,5 @@ std::shared_ptr<CallInvoker> NativeToJsBridge::getDecoratedNativeCallInvoker(
|
||||
return std::make_shared<NativeCallInvoker>(m_delegate, nativeInvoker);
|
||||
}
|
||||
|
||||
RuntimeExecutor NativeToJsBridge::getRuntimeExecutor() {
|
||||
auto runtimeExecutor =
|
||||
[this, isDestroyed = m_destroyed](
|
||||
std::function<void(jsi::Runtime & runtime)> &&callback) {
|
||||
if (*isDestroyed) {
|
||||
return;
|
||||
}
|
||||
runOnExecutorQueue(
|
||||
[callback = std::move(callback)](JSExecutor *executor) {
|
||||
jsi::Runtime *runtime =
|
||||
(jsi::Runtime *)executor->getJavaScriptContext();
|
||||
try {
|
||||
callback(*runtime);
|
||||
} catch (jsi::JSError &originalError) {
|
||||
handleJSError(*runtime, originalError, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
return runtimeExecutor;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
Reference in New Issue
Block a user