mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-11 22:32:38 +08:00
WebWorkers: Add MessageQueueThreadRegistry
Summary: public It is helpful to be able to access the current MessageQueueThread like you would the current Looper. I would do this exactly as Looper does it, but we have forked implementations of MQT for the native bridge and MQT is an interface that can't hold private members. Reviewed By: lexs Differential Revision: D2779072 fb-gh-sync-id: 0ff841d8c490b971697c8e5d45f9c0a57668376b
This commit is contained in:
committed by
facebook-github-bot-0
parent
8c9c7e6286
commit
42e5b2a5bc
@@ -91,6 +91,18 @@ public class SimpleSettableFuture<T> implements Future<T> {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper for {@link #get(long, TimeUnit)} that re-throws get()'s Exceptions as
|
||||
* RuntimeExceptions.
|
||||
*/
|
||||
public @Nullable T getOrThrow(long timeout, TimeUnit unit) {
|
||||
try {
|
||||
return get(timeout, unit);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNotSet() {
|
||||
if (mReadyLatch.getCount() == 0) {
|
||||
throw new RuntimeException("Result has already been set!");
|
||||
|
||||
Reference in New Issue
Block a user