Remove timeout from MessageQueueThreadImpl creation

Reviewed By: oli

Differential Revision: D2880630

fb-gh-sync-id: bd31395abc69750f16a6ab32d11c55af3ec985a4
This commit is contained in:
Andrei Coman
2016-01-29 14:11:36 -08:00
committed by facebook-github-bot-5
parent 041fb59146
commit 8a10fc629a
2 changed files with 15 additions and 4 deletions

View File

@@ -11,7 +11,6 @@ package com.facebook.react.bridge.queue;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import android.os.Looper;
@@ -158,7 +157,7 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
registrationFuture.set(null);
}
});
registrationFuture.getOrThrow(5000, TimeUnit.MILLISECONDS);
registrationFuture.getOrThrow();
}
return mqt;
}
@@ -180,14 +179,14 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
Looper.prepare();
looperFuture.set(Looper.myLooper());
MessageQueueThreadRegistry.register(mqtFuture.getOrThrow(5000, TimeUnit.MILLISECONDS));
MessageQueueThreadRegistry.register(mqtFuture.getOrThrow());
Looper.loop();
}
}, "mqt_" + name);
bgThread.start();
Looper myLooper = looperFuture.getOrThrow(5000, TimeUnit.MILLISECONDS);
Looper myLooper = looperFuture.getOrThrow();
MessageQueueThreadImpl mqt = new MessageQueueThreadImpl(name, myLooper, exceptionHandler);
mqtFuture.set(mqt);

View File

@@ -91,6 +91,18 @@ public class SimpleSettableFuture<T> implements Future<T> {
return mResult;
}
/**
* Convenience wrapper for {@link #get()} that re-throws get()'s Exceptions as
* RuntimeExceptions.
*/
public @Nullable T getOrThrow() {
try {
return get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
/**
* Convenience wrapper for {@link #get(long, TimeUnit)} that re-throws get()'s Exceptions as
* RuntimeExceptions.