|
XNIO API 3.0.7.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xnio.channels.TranslatingSuspendableChannel<C,W>
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>
An abstract wrapped channel.
| Field Summary | |
|---|---|
protected W |
channel
The wrapped channel. |
| Constructor Summary | |
|---|---|
protected |
TranslatingSuspendableChannel(W channel)
Construct a new instance. |
| Method Summary | ||
|---|---|---|
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. |
|
protected void |
clearReadReady()
Indicate that the channel is no longer definitely immediately readable. |
|
protected void |
clearReadRequiresWrite()
Indicate that the channel no longer requires writability for reads to proceed. |
|
protected void |
clearWriteReady()
Indicate that the channel is no longer definitely immediately writable. |
|
protected void |
clearWriteRequiresRead()
Indicate that the channel no longer requires writability for writes to proceed. |
|
void |
close()
Close this channel. |
|
protected void |
closeAction(boolean readShutDown,
boolean writeShutDown)
The action to perform when the channel is closed via the close() method. |
|
boolean |
flush()
Perform channel flush. |
|
protected boolean |
flushAction(boolean shutDown)
The action to perform when the channel is flushed. |
|
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. |
|
|
getOption(Option<T> option)
Get the value of a channel option. |
|
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. |
|
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 |
handleClosed()
Called when the underlying channel is closed. |
|
protected void |
handleReadable()
Called when the underlying channel is readable. |
|
protected void |
handleWritable()
Called when the underlying channel is writable. |
|
boolean |
isOpen()
|
|
boolean |
isReadResumed()
Determine whether reads are resumed. |
|
protected boolean |
isReadShutDown()
Determine whether the channel is shut down for reads. |
|
protected boolean |
isWriteComplete()
|
|
boolean |
isWriteResumed()
Determine whether writes are resumed. |
|
protected boolean |
isWriteShutDown()
Determine whether the channel is shut down for writes. |
|
protected boolean |
readRequiresWrite()
Indicate if the channel is not readable until the write handler is called. |
|
protected void |
removeReadRequiresExternal()
Indicate that one external read task was completed. |
|
protected void |
removeWriteRequiresExternal()
Indicate that one external write task was completed. |
|
void |
resumeReads()
Resume reads on this channel. |
|
void |
resumeWrites()
Resume writes on this channel. |
|
protected boolean |
setClosed()
Set both the channel read and write shut down flags. |
|
|
setOption(Option<T> option,
T value)
Set an option for this channel. |
|
protected void |
setReadReady()
Indicate that the channel is definitely immediately readable, regardless of the underlying channel state. |
|
protected void |
setReadRequiresWrite()
Indicate that the channel will not be readable until the write handler is called. |
|
protected boolean |
setReadShutDown()
Set the channel read shut down flag. |
|
protected void |
setWriteReady()
Indicate that the channel is definitely immediately writable, regardless of the underlying channel state. |
|
protected void |
setWriteRequiresRead()
Indicate that the channel will not be writable until the read handler is called. |
|
protected boolean |
setWriteShutDown()
Set the channel write shut down flag. |
|
void |
shutdownReads()
Perform the read shutdown action if it hasn't been performed already. |
|
protected void |
shutdownReadsAction(boolean writeComplete)
The action to perform when reads are shut down. |
|
void |
shutdownWrites()
Base implementation method which simply delegates the shutdown request to the delegate channel. |
|
protected void |
shutdownWritesAction()
The action to perform when writes are requested to be shut down. |
|
protected void |
shutdownWritesComplete(boolean readShutDown)
Notification that the channel has successfully flushed after having shut down writes. |
|
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()
|
|
protected boolean |
tryAddReadRequiresExternal()
Indicate that read requires an external task to complete. |
|
protected boolean |
tryAddWriteRequiresExternal()
Indicate that write requires an external task to complete. |
|
void |
wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable. |
|
void |
wakeupWrites()
Resume writes on this channel, and force the write listener to be triggered even if the
channel isn't actually writable. |
|
protected boolean |
writeRequiresRead()
Indicate if the channel is not writable until the read handler is called. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final W extends SuspendableChannel channel
| Constructor Detail |
|---|
protected TranslatingSuspendableChannel(W channel)
channel - the channel being wrapped| Method Detail |
|---|
protected void handleReadable()
protected void handleWritable()
protected void handleClosed()
protected void setReadReady()
protected void clearReadReady()
protected void setReadRequiresWrite()
protected boolean readRequiresWrite()
protected void clearReadRequiresWrite()
protected boolean tryAddReadRequiresExternal()
true if the flag was set, false if too many tasks are already outstandingprotected void removeReadRequiresExternal()
tryAddReadRequiresExternal() returned true.
protected boolean setReadShutDown()
true if the channel has fully closed due to this call, false otherwiseprotected void setWriteReady()
protected void clearWriteReady()
protected void setWriteRequiresRead()
protected boolean writeRequiresRead()
protected void clearWriteRequiresRead()
protected boolean tryAddWriteRequiresExternal()
true if the flag was set, false if too many tasks are already outstandingprotected void removeWriteRequiresExternal()
tryAddWriteRequiresExternal() returned true.
protected boolean setWriteShutDown()
true if the channel has fully closed due to this call, false otherwiseprotected boolean setClosed()
true if the channel has fully closed (for the first time) due to this call, false otherwiseprotected 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()
SuspendableReadChannel
isReadResumed 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 suspendWrites()
suspendWrites in interface SuspendableWriteChannelpublic void resumeWrites()
resumeWrites in interface SuspendableWriteChannelpublic boolean isWriteResumed()
SuspendableWriteChannel
isWriteResumed 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 boolean supportsOption(Option<?> option)
supportsOption in interface Configurableoption - the option
true if it is supported
public <T> T getOption(Option<T> option)
throws IOException
getOption in interface ConfigurableT - the type of the option valueoption - the option to get
null if it is not set
IOException - if an I/O error occurred when reading the option
public <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 set
IllegalArgumentException - if the value is not acceptable for this option
IOException - if an I/O error occurred when modifying the option
public final boolean flush()
throws IOException
flushAction(boolean).
flush in interface SuspendableWriteChanneltrue if the flush completed, or false if the operation would block
IOException - if an error occurs
protected boolean flushAction(boolean shutDown)
throws IOException
shutDown parameter is set, and this method returns true, the underlying channel will be
shut down and this method will never be called again (future calls to flush() will flush the underlying
channel until it returns true).
shutDown - true if the channel's write side has been shut down, false otherwise
true if the flush succeeded, false if it would block
IOException - if an error occurs
protected void shutdownWritesComplete(boolean readShutDown)
throws IOException
readShutDown - true if the read side was already shut down, false otherwise
IOException - if an error occurs
public void shutdownReads()
throws IOException
shutdownReads in interface SuspendableReadChannelIOException - if an I/O error occurs
protected void shutdownReadsAction(boolean writeComplete)
throws IOException
writeComplete -
IOException - if an error occursprotected boolean isReadShutDown()
public void shutdownWrites()
throws IOException
shutdownWrites in interface SuspendableWriteChannelIOException - if an I/O error occurs
protected void shutdownWritesAction()
throws IOException
IOException - if an error occursprotected boolean isWriteShutDown()
protected boolean isWriteComplete()
public void awaitReadable()
throws IOException
awaitReadable in interface SuspendableReadChannelInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
IOException - if an I/O error occurs
public void awaitReadable(long time,
TimeUnit timeUnit)
throws IOException
awaitReadable in interface SuspendableReadChanneltime - the time to waittimeUnit - the time unit
InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
IOException - if an I/O error occurspublic XnioExecutor getReadThread()
SuspendableReadChannel
getReadThread in interface SuspendableReadChannelnull if none is configured or available
public void awaitWritable()
throws IOException
awaitWritable in interface SuspendableWriteChannelInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
IOException - if an I/O error occurs
public void awaitWritable(long time,
TimeUnit timeUnit)
throws IOException
awaitWritable in interface SuspendableWriteChanneltime - the time to waittimeUnit - the time unit
InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
IOException - if an I/O error occurspublic XnioExecutor getWriteThread()
SuspendableWriteChannel
getWriteThread in interface SuspendableWriteChannelnull if none is configured or available
public void close()
throws IOException
close in interface Closeableclose in interface Channelclose in interface InterruptibleChannelclose in interface CloseableChannelclose in interface SuspendableWriteChannelIOException - if an I/O error occurs
protected void closeAction(boolean readShutDown,
boolean writeShutDown)
throws IOException
close() method. By default, the underlying
channel is closed.
readShutDown - if reads were previously shut downwriteShutDown - if writes were previously shut down
IOException - if an error occurspublic boolean isOpen()
isOpen in interface Channelpublic W getChannel()
getChannel in interface WrappedChannel<W extends SuspendableChannel>public XnioWorker getWorker()
getWorker in interface CloseableChannelpublic String toString()
toString in class Object
|
XNIO API 3.0.7.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||