Don't block waiting for UI thread to be ready

Reviewed By: astreet

Differential Revision: D3323227

fbshipit-source-id: bc8a815f9dca43c8c1adebc7b2554f931f135f33
This commit is contained in:
Alexander Blom 2016-05-23 09:15:45 -07:00 committed by Facebook Github Bot 3
parent d9737571c4
commit 81e4b4202a

View File

@ -147,20 +147,16 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
final MessageQueueThreadImpl mqt = final MessageQueueThreadImpl mqt =
new MessageQueueThreadImpl(name, mainLooper, exceptionHandler); new MessageQueueThreadImpl(name, mainLooper, exceptionHandler);
// Ensure that the MQT is registered by the time this method returns
if (UiThreadUtil.isOnUiThread()) { if (UiThreadUtil.isOnUiThread()) {
MessageQueueThreadRegistry.register(mqt); MessageQueueThreadRegistry.register(mqt);
} else { } else {
final SimpleSettableFuture<Void> registrationFuture = new SimpleSettableFuture<>();
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
MessageQueueThreadRegistry.register(mqt); MessageQueueThreadRegistry.register(mqt);
registrationFuture.set(null);
} }
}); });
registrationFuture.getOrThrow();
} }
return mqt; return mqt;
} }