Package org.xnio.conduits
Class BlockingStreamSourceConduit
java.lang.Object
org.xnio.conduits.AbstractConduit<D>
org.xnio.conduits.AbstractSourceConduit<D>
org.xnio.conduits.AbstractStreamSourceConduit<StreamSourceConduit>
org.xnio.conduits.BlockingStreamSourceConduit
- All Implemented Interfaces:
Conduit,SourceConduit,StreamSourceConduit
public final class BlockingStreamSourceConduit
extends AbstractStreamSourceConduit<StreamSourceConduit>
A stream source conduit which can switch into and out of blocking mode.
- Author:
- David M. Lloyd
-
Field Summary
Fields inherited from class org.xnio.conduits.AbstractConduit
next -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine whether read notifications are currently enabled.intread(ByteBuffer dst) Read a sequence of bytes from this conduit to the given buffer.longread(ByteBuffer[] dsts, int offs, int len) Read a sequence of bytes from this conduit to the given buffers.voidIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.voidIndicate that calling the conduit'sReadReadyHandlershould be suspended.longtransferTo(long position, long count, FileChannel target) Transfers bytes into the given file from this channel.longtransferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) Transfers bytes into the given channel target.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.AbstractSourceConduit
awaitReadable, awaitReadable, getReadThread, isReadShutdown, setReadReadyHandler, terminateReadsMethods inherited from class org.xnio.conduits.AbstractConduit
getWorkerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xnio.conduits.SourceConduit
awaitReadable, awaitReadable, getReadThread, isReadShutdown, setReadReadyHandler, terminateReads
-
Constructor Details
-
BlockingStreamSourceConduit
Construct a new instance.- Parameters:
next- the delegate conduit to set
-
-
Method Details
-
transferTo
Description copied from interface:StreamSourceConduitTransfers bytes into the given file from this channel.- Specified by:
transferToin interfaceStreamSourceConduit- Overrides:
transferToin classAbstractStreamSourceConduit<StreamSourceConduit>- Parameters:
position- the position within the file from which the transfer is to begincount- the number of bytes to be transferredtarget- the file to write to- Returns:
- the number of bytes (possibly 0) that were actually transferred
- Throws:
IOException- if an I/O error occurs
-
transferTo
public long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException Description copied from interface:StreamSourceConduitTransfers bytes into the given channel target. On entry,throughBufferwill be cleared. On exit, the buffer will be flipped for emptying, and may possibly be empty or may contain data. If this method returns a value less thancount, then the remaining data inthroughBuffermay contain data read from this channel which must be written totargetto complete the operation.- Specified by:
transferToin interfaceStreamSourceConduit- Overrides:
transferToin classAbstractStreamSourceConduit<StreamSourceConduit>- Parameters:
count- the number of bytes to be transferredthroughBuffer- the buffer to copy through.target- the destination to write to- Returns:
- the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached
- Throws:
IOException- if an I/O error occurs
-
read
Description copied from interface:StreamSourceConduitRead a sequence of bytes from this conduit to the given buffer.- Specified by:
readin interfaceStreamSourceConduit- Overrides:
readin classAbstractStreamSourceConduit<StreamSourceConduit>- Returns:
- the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or
this conduit's
SourceConduit.terminateReads()method was previously called - Throws:
IOException- if an error occurs
-
read
Description copied from interface:StreamSourceConduitRead a sequence of bytes from this conduit to the given buffers.- Specified by:
readin interfaceStreamSourceConduit- Overrides:
readin classAbstractStreamSourceConduit<StreamSourceConduit>offs- the offset into the buffer arraylen- the number of buffers to fill- Returns:
- the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or
this conduit's
SourceConduit.terminateReads()method was previously called - Throws:
IOException- if an error occurs
-
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- Overrides:
resumeReadsin classAbstractSourceConduit<StreamSourceConduit>
-
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- Overrides:
wakeupReadsin classAbstractSourceConduit<StreamSourceConduit>
-
suspendReads
public void suspendReads()Description copied from interface:SourceConduitIndicate that calling the conduit'sReadReadyHandlershould be suspended.- Specified by:
suspendReadsin interfaceSourceConduit- Overrides:
suspendReadsin classAbstractSourceConduit<StreamSourceConduit>
-
isReadResumed
public boolean isReadResumed()Description copied from interface:SourceConduitDetermine whether read notifications are currently enabled.- Specified by:
isReadResumedin interfaceSourceConduit- Overrides:
isReadResumedin classAbstractSourceConduit<StreamSourceConduit>- Returns:
trueif read notifications are enabled
-