public abstract class AbstractPrefetchInputStreamByteReceiver extends AbstractByteReceiver
ByteReceiver
interface.
As of the prefetching functionality, a separate daemon thread (retrieved via
an ExecutorService
) reads from the provided InputStream
and
places the datagrams into a datagram queue until the datagram queue's
capacity is reached.
Datagrams are read by the AbstractByteReceiver.readDatagram()
(AbstractByteReceiver.readDatagrams()
)
by them methods popping the datagrams from the datagram queue.
If the queue is empty, then the AbstractByteReceiver.readDatagram()
(
AbstractByteReceiver.readDatagrams()
) method is blocked until the daemon thread places
new datagrams into the queue.AbstractByteReceiver
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
org.refcodes.component.Closable.CloseAutomaton
_datagramQueue, DATAGRAM_QUEUE_SIZE
Constructor and Description |
---|
AbstractPrefetchInputStreamByteReceiver()
Creates an
AbstractInputStreamDatagramReceiver . |
AbstractPrefetchInputStreamByteReceiver(ExecutorService aExecutorService)
Creates an
AbstractInputStreamDatagramReceiver using the given
ExecutorService required for thread generation in an JEE
environment. |
AbstractPrefetchInputStreamByteReceiver(int aQueueCapacity)
Creates an
AbstractInputStreamDatagramReceiver using the given
datagram queue capacity. |
AbstractPrefetchInputStreamByteReceiver(int aQueueCapacity,
ExecutorService aExecutorService)
Creates an
AbstractInputStreamDatagramReceiver using the given
ExecutorService required for thread generation in an JEE
environment. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected boolean |
isOpenable(InputStream aInputStream) |
protected void |
open(InputStream aInputStream) |
hasDatagram, pushDatagram, readDatagram, readDatagrams, releaseAll
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
public AbstractPrefetchInputStreamByteReceiver()
AbstractInputStreamDatagramReceiver
.public AbstractPrefetchInputStreamByteReceiver(ExecutorService aExecutorService)
AbstractInputStreamDatagramReceiver
using the given
ExecutorService
required for thread generation in an JEE
environment.aExecutorService
- The ExecutorService
to be used, when null
then an ExecutorService
something line
Executors.newCachedThreadPool()
is then retrieved.public AbstractPrefetchInputStreamByteReceiver(int aQueueCapacity)
AbstractInputStreamDatagramReceiver
using the given
datagram queue capacity.aQueueCapacity
- The capacity of the prefetch queue before it blocks
until data is read via AbstractByteReceiver.readDatagram()
(
AbstractByteReceiver.readDatagrams()
).public AbstractPrefetchInputStreamByteReceiver(int aQueueCapacity, ExecutorService aExecutorService)
AbstractInputStreamDatagramReceiver
using the given
ExecutorService
required for thread generation in an JEE
environment.aQueueCapacity
- The capacity of the prefetch queue before it blocks
until data is read via AbstractByteReceiver.readDatagram()
(
AbstractByteReceiver.readDatagrams()
).aExecutorService
- The ExecutorService
to be used, when null
then an ExecutorService
something line
Executors.newCachedThreadPool()
is then retrieved.public void close() throws org.refcodes.component.CloseException
close
in interface org.refcodes.component.Closable
close
in class AbstractByteReceiver
org.refcodes.component.CloseException
protected void open(InputStream aInputStream) throws org.refcodes.component.OpenException
org.refcodes.component.OpenException
ConnectionOpenable#open(Object)}
protected boolean isOpenable(InputStream aInputStream)
ConnectionAutomaton#isOpenable(Object)}
Copyright © 2016. All rights reserved.