Package org.refcodes.io
Interface BlockProvider<DATA extends 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 Serializable>
TheBlockProvider
is used to receive datagram blocks (arrays) in a unified way. ThereadDatagrams()
method provides the next available datagram block from the counterpartBlockProvider
orDatagramProvider
; 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 aBlockSender
orDatagramSender
counterpart.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, InterruptedException
Reads (receives) the next datagram block passed from aBlockSender
orDatagramSender
counterpart. In case none datagram block is available, then this method blocks until one is available. When aThread
is waiting for a datagram to be read andThread.interrupt()
is being called, then the operation is aborted and anInterruptedException
is thrown.- Returns:
- The next datagram block sent from the
BlockSender
orDatagramReceiver
counterpart. - Throws:
org.refcodes.component.OpenException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.InterruptedException
- Thrown when aThread
is waiting, sleeping, or otherwise occupied, and theThread
is interrupted, either before or during the activity.
-
readDatagrams
DATA[] readDatagrams(int aBlockSize) throws org.refcodes.component.OpenException, 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
BlockSender
orDatagramReceiver
counterpart. - Throws:
org.refcodes.component.OpenException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.InterruptedException
- Thrown when aThread
is waiting, sleeping, or otherwise occupied, and theThread
is interrupted, either before or during the activity.
-
-