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 and Type | Class and Description |
|---|---|
| private static class | AbstractFramedStreamSinkChannel.
Runnable used to execute the timeout and avoid hangs if the other end does not read the data and the flush is not performed. |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | AWAIT_WRITABLE_TIMEOUT
The maximum timeout to wait on awaitWritable in milliseconds when not specified. |
| private volatile PooledByteBuffer | |
| private volatile boolean | broken
If this channel is broken, updated by multiple threads |
| private volatile boolean | |
| private final C | |
| private final ChannelListener. | |
| private static final PooledByteBuffer | |
| private volatile boolean | finalFrameQueued
If the last frame has been queued. |
| private volatile long | flushExpirationTime
Expiration time for flushing the frame. |
| private volatile boolean | fullyFlushed
If all the data has been written out and the channel has been fully flushed |
| private static final int | FUZZ_FACTOR
Extra timeout to make sure the flush has actually timed out |
| private volatile XnioExecutor. | handle
handle to control the time we are waiting for flushing. |
| private volatile SendFrameHeader | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private final Object | |
| private volatile boolean | readyForFlush
If this channel is ready for flush, updated by multiple threads. |
| private volatile int | state
the state variable, this must only be access by the thread that 'owns' the channel |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private final AbstractFramedStreamSinkChannel. | timeoutRunnable
The timeout runnable to use for the handle. |
| private volatile int | |
| private volatile PooledByteBuffer | |
| private final ChannelListener. | |
| private volatile boolean | |
| private volatile boolean |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| pack-priv void | |
| public void | awaitWritable()
Implements org. Block until this channel becomes writable again. |
| public void | awaitWritable(long
the time to wait l, TimeUnit the time unit timeUnit)Implements org. Block until this channel becomes writable again, or until the timeout expires. |
| protected void | channelForciblyClosed()
Called when a channel has been forcibly closed, and data (frames) have already been written. |
| public void | close()
Implements java. Close this channel. |
| protected SendFrameHeader | |
| public boolean | flush()
Implements org. Flush any waiting partial send or write. |
| pack-priv final void | |
| protected long | Returns: the awaitWritable timeout, in millisecondsReturn the timeout used by awaitWritable and flush tasks. |
| public ByteBuffer | |
| public C | |
| public ChannelListener. | getCloseSetter()
Implements org. Get the setter which can be used to change the close listener for this channel. |
| pack-priv final SendFrameHeader | Returns: The header for the current frame, or nullReturns the header for the current frame. |
| public XnioIoThread | getIoThread()
Implements org. Get the I/O thread associated with this channel. |
| public <T> T | getOption(Option<T>
the option to get tOption)Implements org. Get the value of a channel option. |
| public XnioWorker | getWorker()
Implements org. Get the worker for this channel. |
| pack-priv ChannelListener | |
| public ChannelListener. | getWriteSetter()
Implements org. Get the setter which can be used to change the write listener for this channel. |
| public XnioExecutor | getWriteThread()
Implements org. Get the write thread for this channel. |
| private void | |
| protected void | |
| public boolean | |
| public boolean | |
| protected boolean | |
| protected boolean | |
| protected boolean | |
| protected abstract boolean | |
| public boolean | isOpen()
Implements java. Determine whether this channel is open. |
| public boolean | Returns: true if the channel is ready to be flushed. When a channel is ready to be flushed nothing should modify the buffer, as it may be written out by another thread.
|
| public boolean | isWriteResumed()
Implements org. Determine whether writes are resumed. |
| public boolean | |
| public void | |
| pack-priv final void | |
| protected PooledByteBuffer | |
| private void | |
| private void | |
| public void | resumeWrites()
Implements org. Resume writes on this channel. |
| protected void | |
| protected boolean | |
| public boolean | Returns: true if the buffer was accepted; false if the channel needs to first be flushedPooled ByteBuffer to send. The buffer should have data available. This channel will free the buffer
after sending data pooled)Send a buffer to this channel. |
| protected boolean | |
| private void | |
| public <T> T | setOption(Option<T>
the option to set tOption, T the value of the option to set t)Implements org. Set an option for this channel. |
| public void | shutdownWrites()
Implements org. Indicate that writing is complete for this channel. |
| public boolean | supportsOption(Option<?>
the option option)Implements org. Determine whether an option is supported on this channel. |
| public void | suspendWrites()
Implements org. Suspend further write notifications on this channel. |
| public long | transferFrom(final FileChannel
the file to read from src, final long the position within the file from which the transfer is to begin position, final long the number of bytes to be transferred count)Implements org. Transfer bytes into this channel from the given file. |
| public long | transferFrom(final StreamSourceChannel
the source to read from source, final long the number of bytes to be transferred count, final ByteBuffer the buffer to copy through. throughBuffer)Implements org. Transfers bytes from the given channel source. |
| private void | |
| public void | wakeupWrites()
Implements org.
|
| public long | write(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs, int The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than offset, int srcs.lengthThe maximum number of buffers to be accessed; must be
non-negative and no larger than
length)srcs.length - offsetImplements java. Writes a sequence of bytes to this channel from a subsequence of the given buffers. |
| public long | write(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs)Implements java. Writes a sequence of bytes to this channel from the given buffers. |
| public int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Implements java. Writes a sequence of bytes to this channel from the given buffer. |
| public long | writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs, int The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than srcs.length offset, int The maximum number of buffers to be accessed; must be
non-negative and no larger than
srcs.length - offset length)Implements org. Writes some data to the channel, with the same semantics as
|
| public long | writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs)Implements org. Writes some data to the channel, with the same semantics as
|
| public int | writeFinal(ByteBuffer
The data to write src)Implements org. Writes some data to the channel, with the same semantics as
|