public abstract class AbstractFramedStreamSinkChannel<C extends AbstractFramedChannel<C,R,S>,R extends AbstractFramedStreamSourceChannel<C,R,S>,S extends AbstractFramedStreamSinkChannel<C,R,S>> extends Object implements org.xnio.channels.StreamSinkChannel
Thread safety notes:
The general contract is that this channel is only to be used by a single thread at a time. The only exception to this is during flush. A flush will only happen when readyForFlush
is set, and while this bit is set the buffer must not be modified.
Modifier | Constructor and Description |
---|---|
protected | AbstractFramedStreamSinkChannel(C channel) |
Modifier and Type | Method and Description |
---|---|
void | awaitWritable() |
void | awaitWritable(long l, TimeUnit timeUnit) |
protected void | channelForciblyClosed() Called when a channel has been forcibly closed, and data (frames) have already been written. |
void | close() |
protected PooledByteBuffer | createFrameFooter() |
protected SendFrameHeader | createFrameHeader() |
boolean | flush() |
ByteBuffer | getBuffer() |
C | getChannel() |
org.xnio.ChannelListener.Setter<? extends S> | getCloseSetter() |
org.xnio.XnioIoThread | getIoThread() |
<T> T | getOption(org.xnio.Option<T> tOption) |
org.xnio.XnioWorker | getWorker() |
org.xnio.ChannelListener.Setter<? extends S> | getWriteSetter() |
org.xnio.XnioExecutor | getWriteThread() |
protected void | handleFlushComplete(boolean finalFrame) |
boolean | isBroken() |
protected boolean | isFinalFrameQueued() |
protected boolean | isFirstDataWritten() |
protected boolean | isFlushRequiredOnEmptyBuffer() |
protected abstract boolean | isLastFrame() |
boolean | isOpen() |
boolean | isReadyForFlush() |
boolean | isWriteResumed() |
boolean | isWritesShutdown() Returns true writes have been shutdown |
void | markBroken() |
void | resumeWrites() |
protected void | resumeWritesInternal(boolean wakeup) |
protected boolean | safeToSend() |
boolean | send(PooledByteBuffer pooled) Send a buffer to this channel. |
protected boolean | sendInternal(PooledByteBuffer pooled) |
<T> T | setOption(org.xnio.Option<T> tOption, T t) |
void | shutdownWrites() |
boolean | supportsOption(org.xnio.Option<?> option) |
void | suspendWrites() |
long | transferFrom(FileChannel src, long position, long count) |
long | transferFrom(org.xnio.channels.StreamSourceChannel source, long count, ByteBuffer throughBuffer) |
void | wakeupWrites() |
int | write(ByteBuffer src) |
long | write(ByteBuffer[] srcs) |
long | write(ByteBuffer[] srcs, int offset, int length) |
int | writeFinal(ByteBuffer src) |
long | writeFinal(ByteBuffer[] srcs) |
long | writeFinal(ByteBuffer[] srcs, int offset, int length) |
protected AbstractFramedStreamSinkChannel(C channel)
public long transferFrom(FileChannel src, long position, long count) throws IOException
transferFrom
in interface org.xnio.channels.StreamSinkChannel
IOException
public long transferFrom(org.xnio.channels.StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException
transferFrom
in interface org.xnio.channels.StreamSinkChannel
IOException
public void suspendWrites()
suspendWrites
in interface org.xnio.channels.SuspendableWriteChannel
protected SendFrameHeader createFrameHeader() throws IOException
IOException
protected PooledByteBuffer createFrameFooter()
public boolean isWriteResumed()
isWriteResumed
in interface org.xnio.channels.SuspendableWriteChannel
public void wakeupWrites()
wakeupWrites
in interface org.xnio.channels.SuspendableWriteChannel
public void resumeWrites()
resumeWrites
in interface org.xnio.channels.SuspendableWriteChannel
protected void resumeWritesInternal(boolean wakeup)
public void shutdownWrites() throws IOException
shutdownWrites
in interface org.xnio.channels.SuspendableWriteChannel
IOException
protected boolean isFinalFrameQueued()
public void awaitWritable() throws IOException
awaitWritable
in interface org.xnio.channels.SuspendableWriteChannel
IOException
public void awaitWritable(long l, TimeUnit timeUnit) throws IOException
awaitWritable
in interface org.xnio.channels.SuspendableWriteChannel
IOException
public org.xnio.XnioExecutor getWriteThread()
getWriteThread
in interface org.xnio.channels.SuspendableWriteChannel
public org.xnio.ChannelListener.Setter<? extends S> getWriteSetter()
getWriteSetter
in interface org.xnio.channels.StreamSinkChannel
getWriteSetter
in interface org.xnio.channels.SuspendableWriteChannel
public org.xnio.ChannelListener.Setter<? extends S> getCloseSetter()
getCloseSetter
in interface org.xnio.channels.CloseableChannel
getCloseSetter
in interface org.xnio.channels.StreamSinkChannel
getCloseSetter
in interface org.xnio.channels.SuspendableWriteChannel
public org.xnio.XnioWorker getWorker()
getWorker
in interface org.xnio.channels.CloseableChannel
public org.xnio.XnioIoThread getIoThread()
getIoThread
in interface org.xnio.channels.CloseableChannel
public boolean flush() throws IOException
flush
in interface org.xnio.channels.SuspendableWriteChannel
IOException
protected boolean isFlushRequiredOnEmptyBuffer()
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write
in interface GatheringByteChannel
IOException
public long write(ByteBuffer[] srcs) throws IOException
write
in interface GatheringByteChannel
IOException
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
IOException
public boolean send(PooledByteBuffer pooled) throws IOException
pooled
- Pooled ByteBuffer to send. The buffer should have data available. This channel will free the buffer after sending dataIOException
- if this channel is closedprotected boolean sendInternal(PooledByteBuffer pooled) throws IOException
IOException
protected boolean safeToSend() throws IOException
IOException
public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException
writeFinal
in interface org.xnio.channels.StreamSinkChannel
IOException
public long writeFinal(ByteBuffer[] srcs) throws IOException
writeFinal
in interface org.xnio.channels.StreamSinkChannel
IOException
public int writeFinal(ByteBuffer src) throws IOException
writeFinal
in interface org.xnio.channels.StreamSinkChannel
IOException
protected abstract boolean isLastFrame()
true
If this is the last frame that will be sent on this connectionpublic boolean isReadyForFlush()
public boolean isWritesShutdown()
public boolean isOpen()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
close
in interface InterruptibleChannel
close
in interface org.xnio.channels.CloseableChannel
close
in interface org.xnio.channels.SuspendableWriteChannel
IOException
protected void channelForciblyClosed() throws IOException
IOException
public boolean supportsOption(org.xnio.Option<?> option)
supportsOption
in interface org.xnio.channels.Configurable
public <T> T getOption(org.xnio.Option<T> tOption) throws IOException
getOption
in interface org.xnio.channels.Configurable
IOException
public <T> T setOption(org.xnio.Option<T> tOption, T t) throws IllegalArgumentException, IOException
setOption
in interface org.xnio.channels.Configurable
IllegalArgumentException
IOException
public ByteBuffer getBuffer()
protected void handleFlushComplete(boolean finalFrame)
protected boolean isFirstDataWritten()
public void markBroken()
public C getChannel()
public boolean isBroken()
Copyright © 2015 JBoss by Red Hat. All rights reserved.