/** * @param transactionCtx * @return <tt>true</tt> if we can continue request/response processing, * or <tt>false</tt> if future has been aborted */ boolean setHttpTransactionCtx( final HttpTransactionContext transactionCtx) { this.transactionCtx = transactionCtx; return !delegate.isDone(); } }
@Override public void onWritePossible() throws Exception { future.result(TRUE); }
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return delegate.get(timeout, unit); }
public void abort(Throwable t) { delegate.failure(t); }
/** * Construct failed {@link Future}. */ public static <R> ReadyFutureImpl<R> create(Throwable failure) { final ReadyFutureImpl<R> future = takeFromCache(); if (future != null) { future.failure = failure; return future; } return new ReadyFutureImpl<R>(failure); }
public boolean cancel(boolean mayInterruptIfRunning) { return delegate.cancel(mayInterruptIfRunning); }
@Override public void recycle() { recycle(false); } }
/** * Creates <tt>SafeFutureImpl</tt> */ @SuppressWarnings("unchecked") public SafeFutureImpl() { sync = new Sync(); }
/** * {@inheritDoc} */ @Override public boolean cancel(boolean mayInterruptIfRunning) { isCancelled = true; notifyHaveResult(); return true; }
public boolean isCancelled() { return delegate.isCancelled(); }
GrizzlyResponseFuture(final AsyncHandler asyncHandler) { this.asyncHandler = asyncHandler; delegate = Futures.<V>createSafeFuture(); delegate.addCompletionHandler(this); }
public void done(V result) { delegate.result(result); }
public V get() throws InterruptedException, ExecutionException { return delegate.get(); }
@Override public void onError(Throwable t) { future.failure(makeIOException(t)); } });
/** * Construct {@link Future} with the result. */ public static <R> ReadyFutureImpl<R> create(R result) { final ReadyFutureImpl<R> future = takeFromCache(); if (future != null) { future.result = result; return future; } return new ReadyFutureImpl<R>(result); }
public boolean isDone() { return delegate.isDone(); }
@Override public void shutdownForced() { serverConnection = null; if (shutdownFuture != null) { shutdownFuture.result(NetworkListener.this); } } });
private static void block(final Connection c, final FutureImpl<Boolean> future) { try { final long writeTimeout = c.getTransport().getWriteTimeout(MILLISECONDS); if (writeTimeout != -1) { future.get(writeTimeout, MILLISECONDS); } else { future.get(); } } catch (ExecutionException e) { c.closeWithReason(Exceptions.makeIOException(e.getCause())); } catch (Exception e) { c.closeWithReason(Exceptions.makeIOException(e)); } }
@Override public void onClosed(Closeable closeable, @SuppressWarnings("deprecation") ICloseType type) throws IOException { final CloseReason cr = closeReason; assert cr != null; f.result(cr); } });
@Override public Filter call() throws Exception { return future.get(); } });