Java Code Examples for org.xnio.channels.StreamSourceChannel#suspendReads()
The following examples show how to use
org.xnio.channels.StreamSourceChannel#suspendReads() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractFramedChannel.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void handleEvent(final StreamSourceChannel channel) { //clear the task queue before reading while (!taskRunQueue.isEmpty()) { taskRunQueue.poll().run(); } final R receiver = AbstractFramedChannel.this.receiver; if ((readChannelDone || receivesSuspended) && receiver == null) { channel.suspendReads(); return; } else { ChannelListener listener = receiveSetter.get(); if(listener == null) { listener = DRAIN_LISTENER; } UndertowLogger.REQUEST_IO_LOGGER.tracef("Invoking receive listener", receiver); ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener); } if (readData != null && !readData.isFreed() && channel.isOpen()) { try { runInIoThread(new Runnable() { @Override public void run() { ChannelListeners.invokeChannelListener(channel, FrameReadListener.this); } }); } catch (RejectedExecutionException e) { IoUtils.safeClose(AbstractFramedChannel.this); } } }
Example 2
Source File: DetachableStreamSourceChannel.java From lams with GNU General Public License v2.0 | 5 votes |
public void handleEvent(final StreamSourceChannel channel) { ChannelListener<? super StreamSourceChannel> channelListener = setter.get(); if(channelListener != null) { ChannelListeners.invokeChannelListener(this.channel, channelListener); } else { UndertowLogger.REQUEST_LOGGER.debugf("suspending reads on %s to prevent listener runaway", channel); channel.suspendReads(); } }
Example 3
Source File: UndertowXhrTransport.java From spring-analysis-note with MIT License | 4 votes |
public void setup(StreamSourceChannel channel) { channel.suspendReads(); channel.getReadSetter().set(this); channel.resumeReads(); }
Example 4
Source File: UndertowXhrTransport.java From java-technology-stack with MIT License | 4 votes |
public void setup(StreamSourceChannel channel) { channel.suspendReads(); channel.getReadSetter().set(this); channel.resumeReads(); }
Example 5
Source File: ServletInputStreamImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void handleEvent(final StreamSourceChannel channel) { try { if (asyncContext.isDispatched()) { //this is no longer an async request //we just return //TODO: what do we do here? Revert back to blocking mode? channel.suspendReads(); return; } if (anyAreSet(state, FLAG_FINISHED)) { channel.suspendReads(); return; } readIntoBufferNonBlocking(); if (pooled != null) { channel.suspendReads(); setFlags(FLAG_READY); if (!anyAreSet(state, FLAG_FINISHED)) { setFlags(FLAG_BEING_INVOKED_IN_IO_THREAD); try { request.getServletContext().invokeOnDataAvailable(request.getExchange(), listener); } finally { clearFlags(FLAG_BEING_INVOKED_IN_IO_THREAD); } if(anyAreSet(state, FLAG_CALL_ON_ALL_DATA_READ) && allAreClear(state, FLAG_ON_DATA_READ_CALLED)) { setFlags(FLAG_ON_DATA_READ_CALLED); request.getServletContext().invokeOnAllDataRead(request.getExchange(), listener); } } } else if(anyAreSet(state, FLAG_FINISHED)) { if (allAreClear(state, FLAG_ON_DATA_READ_CALLED)) { setFlags(FLAG_ON_DATA_READ_CALLED); request.getServletContext().invokeOnAllDataRead(request.getExchange(), listener); } } else { channel.resumeReads(); } } catch (final Throwable e) { try { request.getServletContext().invokeRunnable(request.getExchange(), new Runnable() { @Override public void run() { listener.onError(e); } }); } finally { if (pooled != null) { pooled.close(); pooled = null; } IoUtils.safeClose(channel); } } }
Example 6
Source File: UndertowXhrTransport.java From spring4-understanding with Apache License 2.0 | 4 votes |
public void setup(StreamSourceChannel channel) { channel.suspendReads(); channel.getReadSetter().set(this); channel.resumeReads(); }