C - the channel type implemented by this classW - the channel type being wrapped by this classpublic abstract class TranslatingSuspendableChannel<C extends SuspendableChannel,W extends SuspendableChannel> extends Object implements SuspendableChannel, WrappedChannel<W>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
TranslatingSuspendableChannel.Readiness
The readiness of this channel implementation.
|
| Modifier and Type | Field and Description |
|---|---|
protected W |
channel
The wrapped channel.
|
| Modifier | Constructor and Description |
|---|---|
protected |
TranslatingSuspendableChannel(W channel)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
awaitReadable()
Block until this channel becomes readable again.
|
void |
awaitReadable(long time,
TimeUnit timeUnit)
Block until this channel becomes readable again, or until the timeout expires.
|
void |
awaitWritable()
Block until this channel becomes writable again.
|
void |
awaitWritable(long time,
TimeUnit timeUnit)
Block until this channel becomes writable again, or until the timeout expires.
|
void |
close()
Base channel close implementation.
|
boolean |
flush()
Base implementation which delegates the flush request to the channel.
|
W |
getChannel()
Get the channel which is wrapped by this object.
|
ChannelListener.Setter<C> |
getCloseSetter()
Get the setter which can be used to change the close listener for this channel.
|
<T> T |
getOption(Option<T> option)
Get the value of a channel option.
|
protected abstract Object |
getReadLock()
Get the object to use as a read lock.
|
ChannelListener.Setter<C> |
getReadSetter()
Get the setter which can be used to change the read listener for this channel.
|
XnioExecutor |
getReadThread()
Get the read thread for this channel.
|
XnioWorker |
getWorker()
Get the worker for this channel.
|
protected abstract Object |
getWriteLock()
Get the object to use as a write lock.
|
ChannelListener.Setter<C> |
getWriteSetter()
Get the setter which can be used to change the write listener for this channel.
|
XnioExecutor |
getWriteThread()
Get the write thread for this channel.
|
protected void |
handleReadable(W channel)
Called when the underlying channel is readable.
|
protected void |
handleWritable(W channel)
Called when the underlying channel is writable.
|
boolean |
isOpen() |
protected abstract TranslatingSuspendableChannel.Readiness |
isReadable()
Determine whether this channel is known to be (or to not be) readable.
|
boolean |
isReadResumed()
Determine whether reads are resumed.
|
protected abstract TranslatingSuspendableChannel.Readiness |
isWritable()
Determine whether this channel is known to be (or to not be) writable.
|
boolean |
isWriteResumed()
Determine whether writes are resumed.
|
void |
resumeReads()
Resume reads on this channel.
|
protected void |
resumeReadsIfRequested()
Resume reads if the user has requested so.
|
protected void |
resumeReadsIfRequestedAndSuspendWrites()
Resume reads if the user has requested so.
|
void |
resumeWrites()
Resume writes on this channel.
|
protected void |
resumeWritesIfRequested()
Resume writes if the user has requested so.
|
protected void |
resumeWritesIfRequestedAndSuspendReads() |
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
void |
shutdownReads()
Base implementation method which simply delegates the shutdown request to the delegate channel.
|
boolean |
shutdownWrites()
Base implementation method which simply delegates the shutdown request to the delegate channel.
|
boolean |
supportsOption(Option<?> option)
Determine whether an option is supported on this channel.
|
void |
suspendReads()
Suspend further read notifications on this channel.
|
void |
suspendWrites()
Suspend further write notifications on this channel.
|
protected C |
thisTyped()
Get this channel, cast to the implemented channel type.
|
String |
toString() |
void |
wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable. |
void |
wakeupReadsIfRequested() |
void |
wakeupWrites()
Resume writes on this channel, and force the write listener to be triggered even if the
channel isn't actually writable. |
void |
wakeupWritesIfRequested() |
protected final W extends SuspendableChannel channel
protected TranslatingSuspendableChannel(W channel)
channel - the channel being wrappedprotected void handleReadable(W channel)
channel - the underlying channelprotected void handleWritable(W channel)
channel - the underlying channelprotected final C thisTyped()
thispublic ChannelListener.Setter<C> getCloseSetter()
getCloseSetter in interface CloseableChannelgetCloseSetter in interface SuspendableChannelgetCloseSetter in interface SuspendableReadChannelgetCloseSetter in interface SuspendableWriteChannelpublic ChannelListener.Setter<C> getReadSetter()
getReadSetter in interface SuspendableChannelgetReadSetter in interface SuspendableReadChannelpublic ChannelListener.Setter<C> getWriteSetter()
getWriteSetter in interface SuspendableChannelgetWriteSetter in interface SuspendableWriteChannelpublic void suspendReads()
suspendReads in interface SuspendableReadChannelpublic void resumeReads()
resumeReads in interface SuspendableReadChannelpublic boolean isReadResumed()
SuspendableReadChannelisReadResumed in interface SuspendableReadChanneltrue if reads are resumed, false if reads are suspendedpublic void wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable.wakeupReads in interface SuspendableReadChannelpublic void wakeupReadsIfRequested()
protected void resumeReadsIfRequested()
protected void resumeReadsIfRequestedAndSuspendWrites()
public void suspendWrites()
suspendWrites in interface SuspendableWriteChannelpublic void resumeWrites()
resumeWrites in interface SuspendableWriteChannelpublic boolean isWriteResumed()
SuspendableWriteChannelisWriteResumed in interface SuspendableWriteChanneltrue if writes are resumed, false if writes are suspendedpublic void wakeupWrites()
Resume writes on this channel, and force the write listener to be triggered even if the
channel isn't actually writable.wakeupWrites in interface SuspendableWriteChannelpublic void wakeupWritesIfRequested()
protected void resumeWritesIfRequested()
protected void resumeWritesIfRequestedAndSuspendReads()
public boolean supportsOption(Option<?> option)
supportsOption in interface Configurableoption - the optiontrue if it is supportedpublic <T> T getOption(Option<T> option) throws IOException
getOption in interface ConfigurableT - the type of the option valueoption - the option to getnull if it is not setIOException - if an I/O error occurred when reading the optionpublic <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException
setOption in interface ConfigurableT - the type of the option valueoption - the option to setvalue - the value of the option to setIllegalArgumentException - if the value is not acceptable for this optionIOException - if an I/O error occurred when modifying the optionpublic boolean flush()
throws IOException
flush in interface SuspendableWriteChanneltrue if the flush completed, or false if the operation would blockIOException - if an error occurspublic void shutdownReads()
throws IOException
shutdownReads in interface SuspendableReadChannelIOException - if an I/O error occurspublic boolean shutdownWrites()
throws IOException
shutdownWrites in interface SuspendableWriteChanneltrue if the channel was shut down, or false if the operation would blockIOException - if an I/O error occurspublic void awaitReadable()
throws IOException
awaitReadable in interface SuspendableReadChannelInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic void awaitReadable(long time,
TimeUnit timeUnit)
throws IOException
awaitReadable in interface SuspendableReadChanneltime - the time to waittimeUnit - the time unitInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic XnioExecutor getReadThread()
SuspendableReadChannelgetReadThread in interface SuspendableReadChannelnull if none is configured or availablepublic void awaitWritable()
throws IOException
awaitWritable in interface SuspendableWriteChannelInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic void awaitWritable(long time,
TimeUnit timeUnit)
throws IOException
awaitWritable in interface SuspendableWriteChanneltime - the time to waittimeUnit - the time unitInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic XnioExecutor getWriteThread()
SuspendableWriteChannelgetWriteThread in interface SuspendableWriteChannelnull if none is configured or availablepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in interface InterruptibleChannelIOException - if an I/O error occurspublic W getChannel()
getChannel in interface WrappedChannel<W extends SuspendableChannel>protected abstract TranslatingSuspendableChannel.Readiness isReadable()
protected abstract Object getReadLock()
protected abstract TranslatingSuspendableChannel.Readiness isWritable()
protected abstract Object getWriteLock()
public XnioWorker getWorker()
getWorker in interface CloseableChannelCopyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.