mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 09:30:10 +08:00
Remove unused MessageQueueThreadRegistry
Reviewed By: astreet Differential Revision: D5111966 fbshipit-source-id: 2d96c0fe0bb8f7e5c88e200dc09feee265c24890
This commit is contained in:
committed by
Facebook Github Bot
parent
047961fbf7
commit
275ba316c3
@@ -161,14 +161,12 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
|
||||
|
||||
if (UiThreadUtil.isOnUiThread()) {
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
|
||||
MessageQueueThreadRegistry.register(mqt);
|
||||
} else {
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
|
||||
MessageQueueThreadRegistry.register(mqt);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -181,11 +179,10 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
|
||||
* When this method exits, the new MessageQueueThreadImpl is ready to receive events.
|
||||
*/
|
||||
private static MessageQueueThreadImpl startNewBackgroundThread(
|
||||
final String name,
|
||||
long stackSize,
|
||||
QueueThreadExceptionHandler exceptionHandler) {
|
||||
final String name,
|
||||
long stackSize,
|
||||
QueueThreadExceptionHandler exceptionHandler) {
|
||||
final SimpleSettableFuture<Looper> looperFuture = new SimpleSettableFuture<>();
|
||||
final SimpleSettableFuture<MessageQueueThread> mqtFuture = new SimpleSettableFuture<>();
|
||||
Thread bgThread = new Thread(null,
|
||||
new Runnable() {
|
||||
@Override
|
||||
@@ -194,17 +191,12 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
|
||||
Looper.prepare();
|
||||
|
||||
looperFuture.set(Looper.myLooper());
|
||||
MessageQueueThreadRegistry.register(mqtFuture.getOrThrow());
|
||||
|
||||
Looper.loop();
|
||||
}
|
||||
}, "mqt_" + name, stackSize);
|
||||
bgThread.start();
|
||||
|
||||
Looper myLooper = looperFuture.getOrThrow();
|
||||
MessageQueueThreadImpl mqt = new MessageQueueThreadImpl(name, myLooper, exceptionHandler);
|
||||
mqtFuture.set(mqt);
|
||||
|
||||
return mqt;
|
||||
return new MessageQueueThreadImpl(name, myLooper, exceptionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge.queue;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/**
|
||||
* A utility for getting the MessageQueueThread for the current thread. Once there is only one
|
||||
* implementation of MessageQueueThread, this should move to that class.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class MessageQueueThreadRegistry {
|
||||
|
||||
private static ThreadLocal<MessageQueueThread> sMyMessageQueueThread = new ThreadLocal<>();
|
||||
|
||||
/*package*/ static void register(MessageQueueThread mqt) {
|
||||
mqt.assertIsOnThread();
|
||||
sMyMessageQueueThread.set(mqt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the MessageQueueThread that owns the current Thread.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public static MessageQueueThread myMessageQueueThread() {
|
||||
return Assertions.assertNotNull(
|
||||
sMyMessageQueueThread.get(),
|
||||
"This thread doesn't have a MessageQueueThread registered to it!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user