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:
Ramanpreet Nara
2021-04-23 18:16:03 -07:00
committed by Facebook GitHub Bot
parent c68c55469f
commit db3625a3b0
3 changed files with 21 additions and 28 deletions
-21
View File
@@ -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