ShortDestination
, ShortsDestination
, org.refcodes.mixin.Loggable
AbstractShortsReceiver
public abstract class AbstractShortsDestination extends Object implements ShortsDestination, org.refcodes.mixin.Loggable
AbstractShortsDestination
is a base abstract implementation of
the ShortsDestination
interface providing common functionality for
concrete real live implementations.Modifier and Type | Field | Description |
---|---|---|
protected LinkedBlockingQueue<Short> |
_datagramQueue |
|
static int |
DATAGRAM_QUEUE_SIZE |
Constructor | Description |
---|---|
AbstractShortsDestination() |
Constructs a
AbstractShortsDestination with a default sized
blocking queue enabling a maximum of DATAGRAM_QUEUE_SIZE
datagrams.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. |
AbstractShortsDestination(int aCapacity) |
Constructs a
AbstractShortsDestination with a custom sized
blocking queue enabling a maximum of datagrams as specified by the
capacity parameter.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. |
Modifier and Type | Method | Description |
---|---|---|
protected void |
pushDatagram(short aDatagram) |
Pushes a datagram into the receiver and puts it into the blocking queue
containing the so far received datagrams.
|
protected void |
pushDatagrams(short[] aDatagrams) |
Pushes datagrams into the receiver and puts them into the blocking queue
containing the so far received datagrams.
|
protected void |
pushDatagrams(short[] aDatagrams,
int aOffset,
int aLength) |
Pushes datagrams into the receiver and puts them into the blocking queue
containing the so far received datagrams.
|
short[] |
receiveAllShorts() |
Reads (receives) the all currently available data.
|
short |
receiveShort() |
Reads (receives) the next short available, in case none short is
available, then this method blocks until one is available.
|
short[] |
receiveShorts(int aMaxLength) |
Similar to
ShortsDestination.receiveAllShorts() though at maximum the amount of
data as provided returned. |
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
receiveShorts
public static final int DATAGRAM_QUEUE_SIZE
protected LinkedBlockingQueue<Short> _datagramQueue
public AbstractShortsDestination()
AbstractShortsDestination
with a default sized
blocking queue enabling a maximum of DATAGRAM_QUEUE_SIZE
datagrams.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. In case the queue is filled up, adding elements via
pushDatagram(short)
to the queue is blocked until elements are
taken from the queue via receiveShort()
.public AbstractShortsDestination(int aCapacity)
AbstractShortsDestination
with a custom sized
blocking queue enabling a maximum of datagrams as specified by the
capacity parameter.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. In case the queue is filled up, adding elements via
pushDatagram(short)
to the queue is blocked until elements are
taken from the queue via receiveShort()
.aCapacity
- The capacity of the queue holding the received
datagrams.public short receiveShort() throws IOException
receiveShort
in interface ShortDestination
receiveShort
in interface ShortsDestination
ShortsTransmitter
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public short[] receiveAllShorts() throws IOException
receiveAllShorts
in interface ShortsDestination
DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public short[] receiveShorts(int aMaxLength) throws IOException
ShortsDestination.receiveAllShorts()
though at maximum the amount of
data as provided returned.receiveShorts
in interface ShortsDestination
aMaxLength
- 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 method ShortsDestination.receiveAllShorts()
.DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.protected void pushDatagram(short aDatagram) throws IOException
receiveShort()
: Use AbstractBytesReceiver
extension's AbstractBytesReceiver.available()
to test beforehand
whether there is a datagram available.aDatagram
- The datagram to be pushed at the end of the blocking
queue; to be retrieved with the receiveShort()
method.IOException
- the open exceptionprotected void pushDatagrams(short[] aDatagrams) throws IOException
receiveShort()
: Use AbstractBytesReceiver
extension's AbstractBytesReceiver.available()
to test beforehand
whether there is a datagram available.aDatagrams
- The datagrams to be pushed at the end of the blocking
queue; to be retrieved with the receiveShort()
method.IOException
- the open exceptionprotected void pushDatagrams(short[] aDatagrams, int aOffset, int aLength) throws IOException
receiveShort()
: Use AbstractBytesReceiver
extension's AbstractBytesReceiver.available()
to test beforehand
whether there is a datagram available.aDatagrams
- The datagrams to be pushed at the end of the blocking
queue; to be retrieved with the receiveShort()
method.aOffset
- The offset to start taking data from to be pushed.aLength
- The number of elements to be pushed from the offset
onwards.IOException
- the open exceptionCopyright © 2021. All rights reserved.