public void setup(StreamSourceChannel channel) { channel.suspendReads(); channel.getReadSetter().set(this); channel.resumeReads(); }
@Override protected void writingComplete() { this.channel.getWriteSetter().set(null); this.channel.resumeWrites(); }
@Override public void handleEvent(StreamSinkChannel channel) { if(timerKey != null) { timerKey.remove(); } for (ChannelListener<ServerSentEventConnection> listener : closeTasks) { ChannelListeners.invokeChannelListener(ServerSentEventConnection.this, listener); } IoUtils.safeClose(ServerSentEventConnection.this); } });
public Cancellable cancel() { if (futureResult.setCancelled()) { safeClose(channel); } return this; } });
private IoFuture<SslConnection> setupSslConnection(FutureResult<SslConnection> futureResult, IoFuture<StreamConnection> connection) { connection.addNotifier(new IoFuture.HandlingNotifier<StreamConnection, FutureResult<SslConnection>>() { public void handleCancelled(final FutureResult<SslConnection> attachment) { attachment.setCancelled(); } public void handleFailed(final IOException exception, final FutureResult<SslConnection> attachment) { attachment.setException(exception); } }, futureResult); futureResult.addCancelHandler(connection); return futureResult.getIoFuture(); }
public IoFuture<T> open(final ChannelListener<? super T> openListener) { final FutureResult<T> result = new FutureResult<T>(); final IoUtils.RetryingNotifier<T> notifier = new IoUtils.RetryingNotifier<T>(maxTries, result, delegate, openListener); notifier.tryOne(result); return result.getIoFuture(); } }
@Override public void run() { ChannelListeners.invokeChannelListener(WriteDispatchChannel.this, writeSetter.get()); } });
boolean markTerminated() { readBuffer.free(); receiveBuffer.free(); sendBuffer.free(); if (anyAreClear(state, READ_FLAG_SHUTDOWN | WRITE_FLAG_FINISHED)) { state |= READ_FLAG_SHUTDOWN | WRITE_FLAG_SHUTDOWN | WRITE_FLAG_SHUTDOWN2 | WRITE_FLAG_SHUTDOWN3 | WRITE_FLAG_FINISHED; return true; } else { return false; } }
void tryOne(final Result<T> attachment) { final IoFuture<? extends T> ioFuture = delegate.open(openListener); ioFuture.addNotifier(this, attachment); } }
/** * {@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; }
/** * Get a byte string from all remaining bytes of a ByteBuffer. * * @param buffer the buffer * @return the byte string */ public static ByteString getBytes(ByteBuffer buffer) { return new ByteString(Buffers.take(buffer)); }
/** * Add a random amount of random data to the target buffer using the thread-local RNG. * * @param target the target buffer */ public static void addRandom(ByteBuffer target) { addRandom(target, IoUtils.getThreadLocalRandom()); }
/** * {@inheritDoc} */ public IOException getException() throws IllegalStateException { return getState().getException(); }
public Cancellable cancel() { if (futureResult.setCancelled()) { safeClose(channel); } return this; } });
@Override public void handleEvent(ClientConnection channel) { ChannelListeners.invokeChannelListener(HttpClientConnection.this, HttpClientConnection.this.closeSetter.get()); } });
/** * Get a byte string from a ByteBuffer. * * @param buffer the buffer * @param length the number of bytes to get * @return the byte string */ public static ByteString getBytes(ByteBuffer buffer, int length) { return new ByteString(Buffers.take(buffer, length)); }
@Override public void run() { final ChannelListener<? super SslConnection> listener = handshakeSetter.get(); if (listener == null) { return; } ChannelListeners.<SslConnection>invokeChannelListener(UndertowSslConnection.this, listener); } }
/** * Callback method for notification of handshake finished. */ protected void handleHandshakeFinished() { final ChannelListener<? super SslConnection> listener = handshakeSetter.get(); if (listener == null) { return; } ChannelListeners.<SslConnection>invokeChannelListener(this, listener); } }