mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-07 02:08:34 +08:00
give us the ability to create a background UI thread
Reviewed By: javache Differential Revision: D4928689 fbshipit-source-id: 94fa5f3f7c047ad816c7699dcc8bebf9e751b282
This commit is contained in:
committed by
Facebook Github Bot
parent
b4932082c7
commit
6138e20379
@@ -47,6 +47,7 @@ public class ReactContext extends ContextWrapper {
|
||||
private @Nullable CatalystInstance mCatalystInstance;
|
||||
private @Nullable LayoutInflater mInflater;
|
||||
private @Nullable MessageQueueThread mUiMessageQueueThread;
|
||||
private @Nullable MessageQueueThread mUiBackgroundMessageQueueThread;
|
||||
private @Nullable MessageQueueThread mNativeModulesMessageQueueThread;
|
||||
private @Nullable MessageQueueThread mJSMessageQueueThread;
|
||||
private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
|
||||
@@ -71,6 +72,7 @@ public class ReactContext extends ContextWrapper {
|
||||
|
||||
ReactQueueConfiguration queueConfig = catalystInstance.getReactQueueConfiguration();
|
||||
mUiMessageQueueThread = queueConfig.getUIQueueThread();
|
||||
mUiBackgroundMessageQueueThread = queueConfig.getUIBackgroundQueueThread();
|
||||
mNativeModulesMessageQueueThread = queueConfig.getNativeModulesQueueThread();
|
||||
mJSMessageQueueThread = queueConfig.getJSQueueThread();
|
||||
}
|
||||
@@ -279,6 +281,14 @@ public class ReactContext extends ContextWrapper {
|
||||
Assertions.assertNotNull(mUiMessageQueueThread).runOnQueue(runnable);
|
||||
}
|
||||
|
||||
public void assertOnUiBackgroundQueueThread() {
|
||||
Assertions.assertNotNull(mUiBackgroundMessageQueueThread).assertIsOnThread();
|
||||
}
|
||||
|
||||
public void runOnUiBackgroundQueueThread(Runnable runnable) {
|
||||
Assertions.assertNotNull(mUiBackgroundMessageQueueThread).runOnQueue(runnable);
|
||||
}
|
||||
|
||||
public void assertOnNativeModulesQueueThread() {
|
||||
Assertions.assertNotNull(mNativeModulesMessageQueueThread).assertIsOnThread();
|
||||
}
|
||||
@@ -307,6 +317,14 @@ public class ReactContext extends ContextWrapper {
|
||||
Assertions.assertNotNull(mJSMessageQueueThread).runOnQueue(runnable);
|
||||
}
|
||||
|
||||
public void runUIBackgroundRunnable(Runnable runnable) {
|
||||
if (mUiBackgroundMessageQueueThread == null) {
|
||||
runOnNativeModulesQueueThread(runnable);
|
||||
} else {
|
||||
runOnUiBackgroundQueueThread(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the given exception to the current
|
||||
* {@link com.facebook.react.bridge.NativeModuleCallExceptionHandler} if one exists, rethrowing
|
||||
|
||||
Reference in New Issue
Block a user