-
- All Superinterfaces:
java.lang.AutoCloseable,java.nio.channels.Channel,java.io.Closeable,CloseableChannel,Configurable,java.nio.channels.InterruptibleChannel
- All Known Subinterfaces:
BoundMultipointMessageChannel,ConnectedMessageChannel,ConnectedSslStreamChannel,ConnectedStreamChannel,MessageChannel,MulticastMessageChannel,MultipointMessageChannel,StreamChannel,StreamSinkChannel,SuspendableChannel,WritableMessageChannel,WritableMultipointMessageChannel
- All Known Implementing Classes:
AssembledConnectedMessageChannel,AssembledConnectedSslStreamChannel,AssembledConnectedStreamChannel,AssembledMessageChannel,AssembledStreamChannel,ConduitStreamSinkChannel,ConduitWritableMessageChannel,FixedLengthStreamSinkChannel,FramedMessageChannel,NullStreamSinkChannel,SplitStreamSinkChannel,TranslatingSuspendableChannel
public interface SuspendableWriteChannel extends CloseableChannel
A suspendable writable channel. This type of channel is associated with a listener which can suspend and resume writes as needed.
-
-
Field Summary
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidawaitWritable()Block until this channel becomes writable again.voidawaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)Block until this channel becomes writable again, or until the timeout expires.voidclose()Close this channel.booleanflush()Flush any waiting partial send or write.ChannelListener.Setter<? extends SuspendableWriteChannel>getCloseSetter()Get the setter which can be used to change the close listener for this channel.ChannelListener.Setter<? extends SuspendableWriteChannel>getWriteSetter()Get the setter which can be used to change the write listener for this channel.XnioExecutorgetWriteThread()Deprecated.TheCloseableChannel.getIoThread()method should be used instead.booleanisOpen()Determine whether this channel is open.booleanisWriteResumed()Determine whether writes are resumed.voidresumeWrites()Resume writes on this channel.voidshutdownWrites()Indicate that writing is complete for this channel.voidsuspendWrites()Suspend further write notifications on this channel.voidwakeupWrites()Deprecated.Users should instead submitRunnabletasks to the channel thread when this functionality is needed.-
Methods inherited from interface org.xnio.channels.CloseableChannel
getIoThread, getWorker
-
Methods inherited from interface org.xnio.channels.Configurable
getOption, setOption, supportsOption
-
-
-
-
Method Detail
-
suspendWrites
void suspendWrites()
Suspend further write notifications on this channel.
-
resumeWrites
void resumeWrites()
Resume writes on this channel. The write listener will be called as soon as the channel becomes writable.
-
isWriteResumed
boolean isWriteResumed()
Determine whether writes are resumed.- Returns:
trueif writes are resumed,falseif writes are suspended
-
wakeupWrites
@Deprecated void wakeupWrites()
Deprecated.Users should instead submitRunnabletasks to the channel thread when this functionality is needed.Resume writeson this channel, and force the write listener to be triggered even if the channel isn't actually writable.
-
shutdownWrites
void shutdownWrites() throws java.io.IOExceptionIndicate that writing is complete for this channel. Further attempts to write data to this channel after this method is invoked will result in an exception. If this method was already called, calling this method again will have no additional effect. After this method is called, any remaining data still must be flushed out via theflush()method; once this is done, if the read side of the channel was shut down, the channel will automatically close.- Throws:
java.io.IOException- if an I/O error occurs
-
awaitWritable
void awaitWritable() throws java.io.IOExceptionBlock until this channel becomes writable again. This method may return spuriously before the channel becomes writable.- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs- Since:
- 1.2
-
awaitWritable
void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOExceptionBlock until this channel becomes writable again, or until the timeout expires. This method may return spuriously before the channel becomes writable or the timeout expires.- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs- Since:
- 1.2
-
getWriteThread
@Deprecated XnioExecutor getWriteThread()
Deprecated.TheCloseableChannel.getIoThread()method should be used instead.Get the write thread for this channel.- Returns:
- the thread, or
nullif none is configured or available
-
getWriteSetter
ChannelListener.Setter<? extends SuspendableWriteChannel> getWriteSetter()
Get the setter which can be used to change the write listener for this channel.- Returns:
- the setter
- Since:
- 2.0
-
getCloseSetter
ChannelListener.Setter<? extends SuspendableWriteChannel> getCloseSetter()
Get the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.- Specified by:
getCloseSetterin interfaceCloseableChannel- Returns:
- the setter
-
flush
boolean flush() throws java.io.IOExceptionFlush any waiting partial send or write. If there is no data to flush, or if the flush completed successfully, this method will returntrue. If there is data to flush which cannot be immediately written, this method will returnfalse. If this method returnstrueaftershutdownWrites()was called on this channel, the write listener will no longer be invoked on this channel. If this is case and additionally this is a write-only channel or the read side was previously shut down, then the channel will automatically be closed.- Returns:
trueif the message was flushed, orfalseif the result would block- Throws:
java.io.IOException- if an I/O error occurs
-
isOpen
boolean isOpen()
Determine whether this channel is open. This method will returnfalseif all directions are shut down, even if there is unflushed write data pending.- Specified by:
isOpenin interfacejava.nio.channels.Channel- Returns:
trueif the channel is open,falseotherwise
-
close
void close() throws java.io.IOExceptionClose this channel. If data has been written but not flushed, that data may be discarded, depending on the channel implementation. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceCloseableChannel- Specified by:
closein interfacejava.nio.channels.InterruptibleChannel- Throws:
java.io.IOException- if the close failed
-
-