@Override protected boolean setException(IOException exception) { return super.setException(exception); }
/** * Set the result for this operation. Any threads blocking on this instance will be unblocked. * * @param result the result to set * @return {@code false} if the operation was already completed, {@code true} otherwise */ public boolean setResult(final T result) { return ioFuture.setResult(result); }
/** * Add a cancellation handler. The argument will be cancelled whenever the {@code IoFuture} is cancelled. If * the {@code IoFuture} is already cancelled when this method is called, the handler will be called directly. * * @param cancellable the cancel handler */ public void addCancelHandler(final Cancellable cancellable) { ioFuture.addCancelHandler(cancellable); }
/** * {@inheritDoc} */ public <A> IoFuture<T> addNotifier(final Notifier<? super T, A> notifier, final A attachment) { State<T> oldState, newState; do { oldState = getState(); newState = oldState.withNotifier(getNotifierExecutor(), this, notifier, attachment); } while (! compareAndSetState(oldState, newState)); return this; }
/** * {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public T get() throws IOException, CancellationException { switch (await()) { case DONE: return getState().getResult(); case FAILED: throw getState().getException(); case CANCELLED: throw futureMsg.opCancelled(); default: throw new IllegalStateException(); } }
/** * {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public T getInterruptibly() throws IOException, InterruptedException, CancellationException { switch (awaitInterruptibly()) { case DONE: return getState().getResult(); case FAILED: throw getState().getException(); case CANCELLED: throw futureMsg.opCancelled(); default: throw new IllegalStateException(); } }
/** * Acknowledge the cancellation of this operation. * * @return {@code false} if the operation was already completed, {@code true} otherwise */ protected boolean setCancelled() { State<T> oldState; oldState = getState(); if (oldState.getStatus() != Status.WAITING) { return false; } else { @SuppressWarnings("unchecked") State<T> newState = (State<T>) ST_CANCELLED; while (! compareAndSetState(oldState, newState)) { oldState = getState(); if (oldState.getStatus() != Status.WAITING) { return false; } } } oldState.notifyCancelled(this); return true; }
private void doNotify(final AbstractIoFuture<T> future) { future.runNotifier(new NotifierRunnable<T, A>(notifier, future, attachment)); }
/** * {@inheritDoc} */ public Status getStatus() { return getState().getStatus(); }
/** * Run a notifier. Implementors will run the notifier, preferably in another thread. The default implementation * runs the notifier using the {@code Executor} retrieved via {@link #getNotifierExecutor()}. * * @param runnable the runnable task */ protected void runNotifier(final Runnable runnable) { getNotifierExecutor().execute(runnable); }
/** * Acknowledge the cancellation of this operation. * * @return {@code false} if the operation was already completed, {@code true} otherwise */ public boolean setCancelled() { return ioFuture.setCancelled(); } }
/** * Set the result for this operation. Any threads blocking on this instance will be unblocked. * * @param result the result to set * @return {@code false} if the operation was already completed, {@code true} otherwise */ protected boolean setResult(T result) { State<T> oldState; oldState = getState(); if (oldState.getStatus() != Status.WAITING) { return false; } else { State<T> newState = new CompleteState<>(result); while (! compareAndSetState(oldState, newState)) { oldState = getState(); if (oldState.getStatus() != Status.WAITING) { return false; } } } oldState.notifyDone(this, result); return true; }
/** * {@inheritDoc} */ public <A> IoFuture<T> addNotifier(final Notifier<? super T, A> notifier, final A attachment) { State<T> oldState, newState; do { oldState = getState(); newState = oldState.withNotifier(getNotifierExecutor(), this, notifier, attachment); } while (! compareAndSetState(oldState, newState)); return this; }
/** * {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public T get() throws IOException, CancellationException { switch (await()) { case DONE: return getState().getResult(); case FAILED: throw getState().getException(); case CANCELLED: throw futureMsg.opCancelled(); default: throw new IllegalStateException(); } }
/** * {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public T getInterruptibly() throws IOException, InterruptedException, CancellationException { switch (awaitInterruptibly()) { case DONE: return getState().getResult(); case FAILED: throw getState().getException(); case CANCELLED: throw futureMsg.opCancelled(); default: throw new IllegalStateException(); } }
<A> State<T> withNotifier(final Executor executor, final AbstractIoFuture<T> future, final Notifier<? super T, A> notifier, final A attachment) { future.runNotifier(new NotifierRunnable<T, A>(notifier, future, attachment)); return this; }
/** * {@inheritDoc} */ public IOException getException() throws IllegalStateException { return getState().getException(); }
/** * Run a notifier. Implementors will run the notifier, preferably in another thread. The default implementation * runs the notifier using the {@code Executor} retrieved via {@link #getNotifierExecutor()}. * * @param runnable the runnable task */ protected void runNotifier(final Runnable runnable) { getNotifierExecutor().execute(runnable); }
/** * Acknowledge the cancellation of this operation. * * @return {@code false} if the operation was already completed, {@code true} otherwise */ public boolean setCancelled() { return ioFuture.setCancelled(); } }
/** * Set the exception for this operation. Any threads blocking on this instance will be unblocked. * * @param exception the exception to set * @return {@code false} if the operation was already completed, {@code true} otherwise */ public boolean setException(final IOException exception) { return ioFuture.setException(exception); }