Package org.refcodes.io
Interface ShortBlockProvider
-
- All Known Subinterfaces:
ConnectionShortReceiver<CON>,ConnectionShortTransceiver<CON>,LoopbackShortReceiver,LoopbackShortTransceiver,ShortBlockReceiver,ShortProvider,ShortReceiver,ShortTransceiver
- All Known Implementing Classes:
AbstractShortReceiver,LoopbackShortReceiverImpl,LoopbackShortTransceiverImpl,ShortArrayReceiverImpl,ShortReceiverDecorator
- 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 ShortBlockProviderTheShortBlockProvideris used to receive short blocks (arrays) in a unified way. ThereadDatagrams()method provides the next available short block from the counterpartBlockSenderorDatagramSender; 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 short[]readDatagrams()Reads (receives) the next short block passed from aBlockSenderorDatagramSendercounterpart.short[]readDatagrams(int aBlockSize)Similar toreadDatagrams()though at maximum the amount of data as provided by the block-size is returned.
-
-
-
Method Detail
-
readDatagrams
default short[] readDatagrams() throws org.refcodes.component.OpenException, java.lang.InterruptedExceptionReads (receives) the next short block passed from aBlockSenderorDatagramSendercounterpart. In case none short block is available, then this method blocks until one is available. When aThreadis waiting for a short to be read andThread.interrupt()is being called, then the operation is aborted and anInterruptedExceptionis thrown.- 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.
-
readDatagrams
short[] readDatagrams(int aBlockSize) throws org.refcodes.component.OpenException, java.lang.InterruptedExceptionSimilar 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.
-
-