public boolean isDone() { return promise.isDone(); }
private void wait(final Promise<Void> p ) { while ( !p.isDone() ) { try { Thread.sleep(5); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } } }
public boolean isDone() { return deferred.getPromise().isDone(); }
/** * Run the specified chain when the specified promise is resolved. * * @param promise The promise associated with the chain. * @param chain The chain to run when the promise is resolved. */ static <V> void chain(Promise<V> promise, Runnable chain) { if (promise.isDone()) { try { chain.run(); } catch (Throwable t) { uncaughtException(t); } } else { promise.onResolve(chain); } }
/** * Run the specified chain when the specified promise is resolved. * * @param promise The promise associated with the chain. * @param chain The chain to run when the promise is resolved. */ static <V> void chain(Promise<V> promise, Runnable chain) { if (promise.isDone()) { try { chain.run(); } catch (Throwable t) { uncaughtException(t); } } else { promise.onResolve(chain); } }
private BridgeRepository getBridge() throws Exception { Promise<BridgeRepository> promise = repository.getPromise(); if (!promise.isDone()) { repository.resolveWith(readFiles()); } return promise.getValue(); }
private BridgeRepository getBridge() throws Exception { Promise<BridgeRepository> promise = repository.getPromise(); if (!promise.isDone()) { repository.resolveWith(readFiles()); } return promise.getValue(); }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
/** * Return a holder of the result of the specified Promise. * * @since 1.1 */ static <R> Result<R> collect(Promise< ? extends R> promise) { if (promise instanceof PromiseImpl) { @SuppressWarnings("unchecked") PromiseImpl<R> impl = (PromiseImpl<R>) promise; return impl.collect(); } if (!promise.isDone()) { return new Result<R>(new AssertionError("promise not resolved")); } final boolean interrupted = Thread.interrupted(); try { Throwable fail = promise.getFailure(); if (fail == null) { return new Result<R>(promise.getValue()); } return new Result<R>(fail); } catch (Throwable e) { return new Result<R>(e); // propagate new exception } finally { if (interrupted) { // restore interrupt status Thread.currentThread().interrupt(); } } } }
if (backPressure.isDone()) { handleReset(resetWait);
for (final URI uri : getURIs()) { if (freshness.getPromise() .isDone()) { break; // early exit if staleness already detected
for (final URI uri : getURIs()) { if (freshness.getPromise() .isDone()) { break; // early exit if staleness already detected
@Override public Promise<Optional<T>> findFirst() { Deferred<Optional<T>> d = promiseFactory.deferred(); updateNext((event) -> { try { Optional<T> o = null; switch(event.getType()) { case DATA: o = Optional.of(event.getData()); break; case CLOSE: o = Optional.empty(); break; case ERROR: d.fail(event.getFailure()); return ABORT; } if(!d.getPromise().isDone()) d.resolve(o); return ABORT; } catch (Exception e) { close(PushEvent.error(e)); return ABORT; } }); begin(); return d.getPromise(); }
@Override public Promise<Optional<T>> findFirst() { Deferred<Optional<T>> d = promiseFactory.deferred(); updateNext((event) -> { try { Optional<T> o = null; switch(event.getType()) { case DATA: o = Optional.of(event.getData()); break; case CLOSE: o = Optional.empty(); break; case ERROR: d.fail(event.getFailure()); return ABORT; } if(!d.getPromise().isDone()) d.resolve(o); return ABORT; } catch (Exception e) { close(PushEvent.error(e)); return ABORT; } }); begin(); return d.getPromise(); }
@Override public Promise<Optional<T>> findFirst() { Deferred<Optional<T>> d = promiseFactory.deferred(); updateNext((event) -> { try { Optional<T> o = null; switch(event.getType()) { case DATA: o = Optional.of(event.getData()); break; case CLOSE: o = Optional.empty(); break; case ERROR: d.fail(event.getFailure()); return ABORT; } if(!d.getPromise().isDone()) d.resolve(o); return ABORT; } catch (Exception e) { close(PushEvent.error(e)); return ABORT; } }); begin(); return d.getPromise(); }