Fields inherited from interface org.refcodes.mixin.Loggable

Constructor Summary

Constructs a AbstractReceiver 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.

Constructs a AbstractReceiver 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.

Field Detail

DATAGRAM_QUEUE_SIZE

Constructor Detail

AbstractReceiver

public AbstractReceiver​()

Constructs a AbstractReceiver 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(Serializable) to the queue is blocked until
elements are taken from the queue via readDatagram().

AbstractReceiver

public AbstractReceiver​(int aCapacity)

Constructs a AbstractReceiver 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(Serializable) to the queue is blocked until
elements are taken from the queue via readDatagram().

Parameters:

aCapacity - The capacity of the queue holding the received
datagrams.

Method Detail

readDatagram

Reads (receives) the next datagram passed from a DatagramSender
counterpart. In case none datagram is available, then this method blocks
until one is available.
To prevent blocking, use the DatagramReceiver extension's
Receivable.hasDatagram() method to test beforehand whether
a byte is available (in a multi-threaded usage scenario,
Receivable.hasDatagram() is not a reliable indicator
whether this method will block or not).
When a Thread is waiting for a datagram to be read and
Thread.interrupt() is being called, then the operation is aborted
and an InterruptedException is thrown.

releaseAll

pushDatagram

Pushes a datagram into the receiver and puts it into the blocking queue
containing the so far received datagrams. Them datagrams can be retrieved
via readDatagram(): use hasDatagram() to test
beforehand whether there is a datagram available.

Parameters:

aDatagram - The datagram to be pushed at the end of the blocking
queue; to be retrieved with the readDatagram() method.

Throws:

org.refcodes.component.OpenException - the open exception

pushDatagrams

Pushes datagrams into the receiver and puts them into the blocking queue
containing the so far received datagrams. Them datagrams can be retrieved
via readDatagram(): use hasDatagram() to test
beforehand whether there is a datagram available.

Parameters:

aDatagrams - The datagrams to be pushed at the end of the blocking
queue; to be retrieved with the readDatagram() method.

Throws:

org.refcodes.component.OpenException - the open exception

pushDatagrams

Pushes datagrams into the receiver and puts them into the blocking queue
containing the so far received datagrams. Them datagrams can be retrieved
via readDatagram(): use hasDatagram() to test
beforehand whether there is a datagram available.

Parameters:

aDatagrams - The datagrams to be pushed at the end of the blocking
queue; to be retrieved with the readDatagram() method.

aOffset - The offset to start taking data from to be pushed.

aLength - The number of elements to be pushed from the offset
onwards.