/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks return this; }
/** * {@inheritDoc} */ public Promise<T> onResolve(Runnable callback) { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks return this; }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks return this; }
/** * Resolve this Promise. * * @param v The value of this Promise. * @param f The failure of this Promise. */ void resolve(T v, Throwable f) { // critical section: only one resolver at a time synchronized (resolved) { if (resolved.getCount() == 0) { throw new IllegalStateException("Already resolved"); } /* * The resolved state variables must be set before opening the * latch. This safely publishes them to be read by other threads * that must verify the latch is open before reading. */ value = v; fail = f; resolved.countDown(); } notifyCallbacks(); // call any registered callbacks }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { requireNonNull(callback); if (factory.allowCurrentThread() && isDone()) { try { callback.run(); } catch (Throwable t) { uncaughtException(t); } } else { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks } return this; }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { requireNonNull(callback); if (factory.allowCurrentThread() && isDone()) { try { callback.run(); } catch (Throwable t) { uncaughtException(t); } } else { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks } return this; }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { requireNonNull(callback); if (factory.allowCurrentThread() && isDone()) { try { callback.run(); } catch (Throwable t) { uncaughtException(t); } } else { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks } return this; }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { requireNonNull(callback); if (factory.allowCurrentThread() && isDone()) { try { callback.run(); } catch (Throwable t) { uncaughtException(t); } } else { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks } return this; }
/** * {@inheritDoc} */ @Override public Promise<T> onResolve(Runnable callback) { requireNonNull(callback); if (factory.allowCurrentThread() && isDone()) { try { callback.run(); } catch (Throwable t) { uncaughtException(t); } } else { callbacks.offer(callback); notifyCallbacks(); // call any registered callbacks } return this; }