Package org.refcodes.io
Interface BlockProvider<DATA extends java.io.Serializable>
-
- Type Parameters:
DATA- The type of the datagram block (array) to be operated with. Do not provide an array type as the methods use to generic type for defining an array argument.
- All Known Subinterfaces:
BidirectionalConnectionTransceiver<DATA,INPUT,OUTPUT>,BidirectionalStreamConnectionTransceiver<DATA>,BlockReceiver<DATA>,BlockTransceiver<DATA>,ConnectionReceiver<DATA,CON>,ConnectionTransceiver<DATA,CON>,InputStreamConnectionReceiver<DATA>,LoopbackReceiver<DATA>,LoopbackTransceiver<DATA>,Provider<DATA>,Receiver<DATA>,Transceiver<DATA>
- All Known Implementing Classes:
AbstractInputStreamReceiver,AbstractPrefetchInputStreamReceiver,AbstractReceiver,BidirectionalStreamConnectionTransceiverImpl,BidirectionalStreamTransceiverImpl,InputStreamConnectionReceiverImpl,InputStreamReceiverImpl,LoopbackReceiverImpl,LoopbackTransceiverImpl,PrefetchBidirectionalStreamConnectionTransceiverImpl,PrefetchBidirectionalStreamTransceiverImpl,PrefetchInputStreamConnectionReceiverImpl,PrefetchInputStreamReceiverImpl,ReceiverDecorator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface BlockProvider<DATA extends java.io.Serializable>TheBlockProvideris used to receive datagram blocks (arrays) in a unified way. ThereadDatagrams()method provides the next available datagram block from the counterpartBlockProviderorDatagramProvider; in case there is none available, then this method halts until one is available.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default DATA[]readDatagrams()Reads (receives) the next datagram block passed from aBlockSenderorDatagramSendercounterpart.DATA[]readDatagrams(int aBlockSize)Similar toreadDatagrams()though at maximum the amount of data as provided by the block-size is returned.
-
-
-
Method Detail
-
readDatagrams
default DATA[] readDatagrams() throws org.refcodes.component.OpenException, java.lang.InterruptedException
Reads (receives) the next datagram block passed from aBlockSenderorDatagramSendercounterpart. In case none datagram block is available, then this method blocks until one is available. When aThreadis waiting for a datagram to be read andThread.interrupt()is being called, then the operation is aborted and anInterruptedExceptionis thrown.- Returns:
- The next datagram block sent from the
BlockSenderorDatagramReceivercounterpart. - Throws:
org.refcodes.component.OpenException- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.java.lang.InterruptedException- Thrown when aThreadis waiting, sleeping, or otherwise occupied, and theThreadis interrupted, either before or during the activity.
-
readDatagrams
DATA[] readDatagrams(int aBlockSize) throws org.refcodes.component.OpenException, java.lang.InterruptedException
Similar toreadDatagrams()though at maximum the amount of data as provided by the block-size is returned.- Parameters:
aBlockSize- The block-size which is not to exceeded by the returned data. A value of -1 specifies to retrieve all available datagrams (same behavior as methodreadDatagrams().- Returns:
- The next short block sent from the
BlockSenderorDatagramReceivercounterpart. - Throws:
org.refcodes.component.OpenException- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.java.lang.InterruptedException- Thrown when aThreadis waiting, sleeping, or otherwise occupied, and theThreadis interrupted, either before or during the activity.
-
-