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()
this
public ChannelListener.Setter<C> getCloseSetter()
getCloseSetter
in interface CloseableChannel
getCloseSetter
in interface SuspendableChannel
getCloseSetter
in interface SuspendableReadChannel
getCloseSetter
in interface SuspendableWriteChannel
public ChannelListener.Setter<C> getReadSetter()
getReadSetter
in interface SuspendableChannel
getReadSetter
in interface SuspendableReadChannel
public ChannelListener.Setter<C> getWriteSetter()
getWriteSetter
in interface SuspendableChannel
getWriteSetter
in interface SuspendableWriteChannel
public void suspendReads()
suspendReads
in interface SuspendableReadChannel
public void resumeReads()
resumeReads
in interface SuspendableReadChannel
public boolean isReadResumed()
SuspendableReadChannel
isReadResumed
in interface SuspendableReadChannel
true
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 SuspendableReadChannel
public void wakeupReadsIfRequested()
protected void resumeReadsIfRequested()
protected void resumeReadsIfRequestedAndSuspendWrites()
public void suspendWrites()
suspendWrites
in interface SuspendableWriteChannel
public void resumeWrites()
resumeWrites
in interface SuspendableWriteChannel
public boolean isWriteResumed()
SuspendableWriteChannel
isWriteResumed
in interface SuspendableWriteChannel
true
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 SuspendableWriteChannel
public void wakeupWritesIfRequested()
protected void resumeWritesIfRequested()
protected void resumeWritesIfRequestedAndSuspendReads()
public boolean supportsOption(Option<?> option)
supportsOption
in interface Configurable
option
- the optiontrue
if it is supportedpublic <T> T getOption(Option<T> option) throws IOException
getOption
in interface Configurable
T
- 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 Configurable
T
- 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 SuspendableWriteChannel
true
if the flush completed, or false
if the operation would blockIOException
- if an error occurspublic void shutdownReads() throws IOException
shutdownReads
in interface SuspendableReadChannel
IOException
- if an I/O error occurspublic boolean shutdownWrites() throws IOException
shutdownWrites
in interface SuspendableWriteChannel
true
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 SuspendableReadChannel
InterruptedIOException
- 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 SuspendableReadChannel
time
- 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()
SuspendableReadChannel
getReadThread
in interface SuspendableReadChannel
null
if none is configured or availablepublic void awaitWritable() throws IOException
awaitWritable
in interface SuspendableWriteChannel
InterruptedIOException
- 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 SuspendableWriteChannel
time
- 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()
SuspendableWriteChannel
getWriteThread
in interface SuspendableWriteChannel
null
if none is configured or availablepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
close
in interface InterruptibleChannel
IOException
- 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 CloseableChannel
Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.