/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
/** * Resolve this Promise. * <p> * If this Promise was already resolved, throw IllegalStateException. * Otherwise, resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. * @throws IllegalStateException If this Promise was already resolved. */ void resolve(T v, Throwable f) { if (!tryResolve(v, f)) { throw new IllegalStateException("Already resolved"); } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
@Override public void run() { if (promiseCount.decrementAndGet() != 0) { return; } List<T> value = new ArrayList<>(promises.size()); List<Promise< ? >> failed = new ArrayList<>(promises.size()); Throwable cause = null; for (Promise<S> p : promises) { Result<S> result = PromiseImpl.collect(p); if (result.fail != null) { failed.add(p); if (cause == null) { cause = result.fail; } } else { value.add(result.value); } } if (failed.isEmpty()) { chained.tryResolve(value, null); } else { chained.tryResolve(null, new FailedPromisesException(failed, cause)); } } }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object. * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object. * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object. * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object. * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object. * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }
/** * Returns a new Promise that will hold the result of the specified task. * <p> * The returned Promise uses the callback executor and scheduled executor of * this PromiseFactory object * <p> * The specified task will be executed on the {@link #executor() callback * executor}. * * @param <T> The value type associated with the returned Promise. * @param task The task whose result will be available from the returned * Promise. * @return A new Promise that will hold the result of the specified task. */ public <T> Promise<T> submit(Callable< ? extends T> task) { DeferredPromiseImpl<T> promise = new DeferredPromiseImpl<>(this); Runnable submit = promise.new Submit(task); try { executor().execute(submit); } catch (Exception t) { promise.tryResolve(null, t); } return promise.orDone(); }