Add flushing to RuntimeExecutor

Summary:
## Motivation
With the bridge, every call into JS flushes the queue of NativeModule calls. Fabric bypasses this mechanism, because it uses a RuntimeExecutor that schedules work directly on the JavaScript thread. This diff makes Fabric's RuntimeExecutor also flush the queue of NativeModule calls.

This likely won't fix anything in Fabric, because we don't execute any async NativeModule calls on Fb4a. However, this is necessary for the drainMicrotask work we're doing in D27729702 (https://github.com/facebook/react-native/commit/73108477589a18cecb303ef556fa3da02f8ca1b8), because (1) we need to drain the Hermes microtask queue on every call from C++ -> JavaScript (2) we drain the microtask queue [inside JSIExecutor::flush()](https://github.com/facebook/react-native/blob/de477a0df6da770e579892d4875a8995c430ebdf/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp#L427,L445).

Changelog: [Android][Fixed] - Flush JSIExecutor in Fabric's RuntimeExecutor

Reviewed By: JoshuaGross

Differential Revision: D27975839

fbshipit-source-id: 27f031fb36593253da116a033e30998475eb1473
This commit is contained in:
Ramanpreet Nara
2021-04-23 18:16:03 -07:00
committed by Facebook GitHub Bot
parent db3625a3b0
commit c0ec82e61e
5 changed files with 19 additions and 11 deletions
@@ -550,7 +550,11 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
@Override
public native RuntimeExecutor getRuntimeExecutor();
public RuntimeExecutor getRuntimeExecutor() {
return getRuntimeExecutor(false);
}
public native RuntimeExecutor getRuntimeExecutor(boolean shouldFlush);
@Override
public void addJSIModules(List<JSIModuleSpec> jsiModules) {