Package org.xnio.conduits
Class AbstractSynchronizedSourceConduit<D extends SourceConduit>
java.lang.Object
org.xnio.conduits.AbstractConduit<D>
org.xnio.conduits.AbstractSynchronizedConduit<D>
org.xnio.conduits.AbstractSynchronizedSourceConduit<D>
- All Implemented Interfaces:
Conduit,SourceConduit
- Direct Known Subclasses:
SynchronizedMessageSourceConduit,SynchronizedStreamSourceConduit
public abstract class AbstractSynchronizedSourceConduit<D extends SourceConduit>
extends AbstractSynchronizedConduit<D>
implements SourceConduit
An abstract synchronized source conduit. All conduit operations are wrapped in synchronization blocks for simplified
thread safety.
- Author:
- David M. Lloyd
-
Field Summary
Fields inherited from class org.xnio.conduits.AbstractSynchronizedConduit
lockFields inherited from class org.xnio.conduits.AbstractConduit
next -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a new instance.protectedAbstractSynchronizedSourceConduit(D next, Object lock) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidBlock until this channel becomes readable again.voidawaitReadable(long time, TimeUnit timeUnit) Block until this conduit becomes readable again, or until the timeout expires.Get the XNIO read thread.booleanDetermine whether read notifications are currently enabled.booleanDetermine whether reads have been shut down on this conduit.voidIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.voidsetReadReadyHandler(ReadReadyHandler handler) Set the handler which should receive readiness notifications.voidIndicate that calling the conduit'sReadReadyHandlershould be suspended.voidIndicate that no more data will be read from this conduit.voidIndicate that the conduit'sReadReadyHandlershould be invoked immediately, and then again as soon as data can be read without blocking.Methods inherited from class org.xnio.conduits.AbstractConduit
getWorker
-
Constructor Details
-
AbstractSynchronizedSourceConduit
Construct a new instance. A new lock object is created.- Parameters:
next- the next conduit in the chain
-
AbstractSynchronizedSourceConduit
Construct a new instance.- Parameters:
next- the next conduit in the chainlock- the lock object to use
-
-
Method Details
-
terminateReads
Description copied from interface:SourceConduitIndicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.- Specified by:
terminateReadsin interfaceSourceConduit- Throws:
IOException- if there was a problem
-
isReadShutdown
public boolean isReadShutdown()Description copied from interface:SourceConduitDetermine whether reads have been shut down on this conduit.- Specified by:
isReadShutdownin interfaceSourceConduit- Returns:
trueif writes are shut down,falseotherwise
-
resumeReads
public void resumeReads()Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.- Specified by:
resumeReadsin interfaceSourceConduit
-
suspendReads
public void suspendReads()Description copied from interface:SourceConduitIndicate that calling the conduit'sReadReadyHandlershould be suspended.- Specified by:
suspendReadsin interfaceSourceConduit
-
wakeupReads
public void wakeupReads()Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked immediately, and then again as soon as data can be read without blocking.- Specified by:
wakeupReadsin interfaceSourceConduit
-
isReadResumed
public boolean isReadResumed()Description copied from interface:SourceConduitDetermine whether read notifications are currently enabled.- Specified by:
isReadResumedin interfaceSourceConduit- Returns:
trueif read notifications are enabled
-
awaitReadable
Description copied from interface:SourceConduitBlock until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadablein interfaceSourceConduit- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
awaitReadable
Description copied from interface:SourceConduitBlock until this conduit becomes readable again, or until the timeout expires. This method may return spuriously before the conduit becomes readable or the timeout expires.- Specified by:
awaitReadablein interfaceSourceConduit- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
getReadThread
Description copied from interface:SourceConduitGet the XNIO read thread.- Specified by:
getReadThreadin interfaceSourceConduit- Returns:
- the XNIO read thread
-
setReadReadyHandler
Description copied from interface:SourceConduitSet 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:
setReadReadyHandlerin interfaceSourceConduit
-