mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 09:30:10 +08:00
enable the usage of the BGUI thread
Reviewed By: javache Differential Revision: D4928729 fbshipit-source-id: 2a3baa01856cb7145d5f0155da0b959c330b7425
This commit is contained in:
committed by
Facebook Github Bot
parent
28aaa88808
commit
513da6fcf2
@@ -933,12 +933,14 @@ public class ReactInstanceManager {
|
||||
? mNativeModuleCallExceptionHandler
|
||||
: mDevSupportManager;
|
||||
CatalystInstanceImpl.Builder catalystInstanceBuilder = new CatalystInstanceImpl.Builder()
|
||||
.setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
|
||||
.setJSExecutor(jsExecutor)
|
||||
.setRegistry(nativeModuleRegistry)
|
||||
.setJSModuleRegistry(jsModulesBuilder.build())
|
||||
.setJSBundleLoader(jsBundleLoader)
|
||||
.setNativeModuleCallExceptionHandler(exceptionHandler);
|
||||
.setReactQueueConfigurationSpec(mUseSeparateUIBackgroundThread ?
|
||||
ReactQueueConfigurationSpec.createWithSeparateUIBackgroundThread() :
|
||||
ReactQueueConfigurationSpec.createDefault())
|
||||
.setJSExecutor(jsExecutor)
|
||||
.setRegistry(nativeModuleRegistry)
|
||||
.setJSModuleRegistry(jsModulesBuilder.build())
|
||||
.setJSBundleLoader(jsBundleLoader)
|
||||
.setNativeModuleCallExceptionHandler(exceptionHandler);
|
||||
|
||||
ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_START);
|
||||
// CREATE_CATALYST_INSTANCE_END is in JSCExecutor.cpp
|
||||
|
||||
@@ -308,6 +308,10 @@ public class ReactContext extends ContextWrapper {
|
||||
Assertions.assertNotNull(mJSMessageQueueThread).runOnQueue(runnable);
|
||||
}
|
||||
|
||||
public boolean hasUIBackgroundRunnableThread() {
|
||||
return mUiBackgroundMessageQueueThread != null;
|
||||
}
|
||||
|
||||
public void runUIBackgroundRunnable(Runnable runnable) {
|
||||
if (mUiBackgroundMessageQueueThread == null) {
|
||||
runOnNativeModulesQueueThread(runnable);
|
||||
|
||||
@@ -89,6 +89,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
private final NativeModuleRegistry mJavaRegistry;
|
||||
private final NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
|
||||
private final MessageQueueThread mNativeModulesQueueThread;
|
||||
private final @Nullable MessageQueueThread mUIBackgroundQueueThread;
|
||||
private boolean mInitialized = false;
|
||||
private volatile boolean mAcceptCalls = false;
|
||||
|
||||
@@ -118,6 +119,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
mJSBundleLoader = jsBundleLoader;
|
||||
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
|
||||
mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
|
||||
mUIBackgroundQueueThread = mReactQueueConfiguration.getUIBackgroundQueueThread();
|
||||
mTraceListener = new JSProfilerTraceListener(this);
|
||||
|
||||
FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
|
||||
@@ -126,6 +128,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
jsExecutor,
|
||||
mReactQueueConfiguration.getJSQueueThread(),
|
||||
mNativeModulesQueueThread,
|
||||
mUIBackgroundQueueThread,
|
||||
mJavaRegistry.getJavaModules(this),
|
||||
mJavaRegistry.getCxxModules());
|
||||
FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
|
||||
@@ -171,6 +174,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
JavaScriptExecutor jsExecutor,
|
||||
MessageQueueThread jsQueue,
|
||||
MessageQueueThread moduleQueue,
|
||||
MessageQueueThread uiBackgroundQueue,
|
||||
Collection<JavaModuleWrapper> javaModules,
|
||||
Collection<ModuleHolder> cxxModules);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user