- java.lang.Object
-
- org.xnio.conduits.AbstractConduit<D>
-
- org.xnio.conduits.AbstractSinkConduit<D>
-
- All Implemented Interfaces:
Conduit,SinkConduit
- Direct Known Subclasses:
AbstractMessageSinkConduit,AbstractStreamSinkConduit,FramingMessageSinkConduit,MessageStreamSinkConduit
public abstract class AbstractSinkConduit<D extends SinkConduit> extends AbstractConduit<D> implements SinkConduit
An abstract base class for filtering output conduits.- Author:
- David M. Lloyd
-
-
Field Summary
-
Fields inherited from class org.xnio.conduits.AbstractConduit
next
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSinkConduit(D next)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete 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 conduit becomes writable again, or until the timeout expires.booleanflush()Flush out any unwritten, buffered output.XnioIoThreadgetWriteThread()Get the write thread for this conduit.booleanisWriteResumed()Determine whether write notifications are currently enabled.booleanisWriteShutdown()Determine whether writes have been fully shut down on this conduit.voidresumeWrites()Indicate that the conduit'sWriteReadyHandlershould be invoked as soon as data can be written without blocking.voidsetWriteReadyHandler(WriteReadyHandler handler)Set the handler which should receive readiness notifications.voidsuspendWrites()Indicate that calling the conduit'sWriteReadyHandlershould be suspended.voidterminateWrites()Signal that no more write data is forthcoming.voidtruncateWrites()Terminate writes and discard any outstanding write data.voidwakeupWrites()Indicate that the conduit'sWriteReadyHandlershould be invoked immediately, and then again as soon as data can be written without blocking.-
Methods inherited from class org.xnio.conduits.AbstractConduit
getWorker
-
-
-
-
Constructor Detail
-
AbstractSinkConduit
protected AbstractSinkConduit(D next)
Construct a new instance.- Parameters:
next- the delegate conduit to set
-
-
Method Detail
-
terminateWrites
public void terminateWrites() throws java.io.IOExceptionDescription copied from interface:SinkConduitSignal that no more write data is forthcoming. The conduit must beSinkConduit.flush()ed before it is considered to be shut down.- Specified by:
terminateWritesin interfaceSinkConduit- Throws:
java.io.IOException
-
isWriteShutdown
public boolean isWriteShutdown()
Description copied from interface:SinkConduitDetermine whether writes have been fully shut down on this conduit.- Specified by:
isWriteShutdownin interfaceSinkConduit- Returns:
trueif writes are fully shut down,falseotherwise
-
resumeWrites
public void resumeWrites()
Description copied from interface:SinkConduitIndicate that the conduit'sWriteReadyHandlershould be invoked as soon as data can be written without blocking.- Specified by:
resumeWritesin interfaceSinkConduit
-
suspendWrites
public void suspendWrites()
Description copied from interface:SinkConduitIndicate that calling the conduit'sWriteReadyHandlershould be suspended.- Specified by:
suspendWritesin interfaceSinkConduit
-
wakeupWrites
public void wakeupWrites()
Description copied from interface:SinkConduitIndicate that the conduit'sWriteReadyHandlershould be invoked immediately, and then again as soon as data can be written without blocking.- Specified by:
wakeupWritesin interfaceSinkConduit
-
isWriteResumed
public boolean isWriteResumed()
Description copied from interface:SinkConduitDetermine whether write notifications are currently enabled.- Specified by:
isWriteResumedin interfaceSinkConduit- Returns:
trueif write notifications are enabled
-
awaitWritable
public void awaitWritable() throws java.io.IOExceptionDescription copied from interface:SinkConduitBlock until this channel becomes writable again. This method may return spuriously before the channel becomes writable.- Specified by:
awaitWritablein interfaceSinkConduit- 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
-
awaitWritable
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOExceptionDescription copied from interface:SinkConduitBlock until this conduit becomes writable again, or until the timeout expires. This method may return spuriously before the conduit becomes writable or the timeout expires.- Specified by:
awaitWritablein interfaceSinkConduit- 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
-
getWriteThread
public XnioIoThread getWriteThread()
Description copied from interface:SinkConduitGet the write thread for this conduit.- Specified by:
getWriteThreadin interfaceSinkConduit- Returns:
- the thread, or
nullif none is configured or available
-
setWriteReadyHandler
public void setWriteReadyHandler(WriteReadyHandler handler)
Description copied from interface:SinkConduitSet the handler which should receive readiness notifications. A filter may pass this invocation on to the filter it wraps, or it may substitute itself.- Specified by:
setWriteReadyHandlerin interfaceSinkConduit
-
truncateWrites
public void truncateWrites() throws java.io.IOExceptionDescription copied from interface:SinkConduitTerminate writes and discard any outstanding write data. The conduit is terminated and flushed regardless of the outcome of this method.- Specified by:
truncateWritesin interfaceSinkConduit- Throws:
java.io.IOException- if channel termination failed for some reason
-
flush
public boolean flush() throws java.io.IOExceptionDescription copied from interface:SinkConduitFlush out any unwritten, buffered output.- Specified by:
flushin interfaceSinkConduit- Returns:
trueif everything is flushed,falseotherwise- Throws:
java.io.IOException- if flush fails
-
-