DATA
- The type of the datagram to be operated with.org.refcodes.component.Closable
, org.refcodes.component.Closable.CloseAutomaton
, org.refcodes.component.ClosedAccessor
, org.refcodes.component.ConnectableComponent
, org.refcodes.component.ConnectableComponent.ConnectableAutomaton
, org.refcodes.component.ConnectionStatusAccessor
, org.refcodes.component.OpenedAccessor
, BlockProvider<DATA>
, BlockReceiver<DATA>
, DatagramProvider<DATA>
, DatagramReceiver<DATA>
, Provider<DATA>
, Receivable
, Receiver<DATA>
, org.refcodes.mixin.Releaseable
PrefetchBidirectionalStreamConnectionTransceiverImpl
, PrefetchInputStreamConnectionReceiverImpl
public abstract class AbstractPrefetchInputStreamReceiver<DATA extends Serializable> extends AbstractReceiver<DATA>
Receiver
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 AbstractReceiver.readDatagram()
(AbstractReceiver.readDatagrams()
)
by them methods popping the datagrams from the datagram queue.
If the queue is empty, then the AbstractReceiver.readDatagram()
(
AbstractReceiver.readDatagrams()
) method is blocked until the daemon thread places
new datagrams into the queue.
See also AbstractReceiver
.org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
DATAGRAM_QUEUE_SIZE
Constructor | Description |
---|---|
AbstractPrefetchInputStreamReceiver() |
Creates an
AbstractPrefetchInputStreamReceiver . |
AbstractPrefetchInputStreamReceiver(int aQueueCapacity) |
Creates an
AbstractPrefetchInputStreamReceiver using the given
datagram queue capacity. |
AbstractPrefetchInputStreamReceiver(int aQueueCapacity,
ExecutorService aExecutorService) |
Creates an
AbstractPrefetchInputStreamReceiver using the given
ExecutorService required for thread generation in an JEE
environment. |
AbstractPrefetchInputStreamReceiver(ExecutorService aExecutorService) |
Creates an
AbstractPrefetchInputStreamReceiver using the given
ExecutorService required for thread generation in an JEE
environment. |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
protected boolean |
isOpenable(InputStream aInputStream) |
Checks if is openable.
|
protected void |
open(InputStream aInputStream) |
Open, see also
ConnectionOpenable.open(Object) . |
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
hasDatagram, pushDatagram, pushDatagrams, pushDatagrams, readDatagram, readDatagrams, releaseAll
closeIn, closeQuietly, closeUnchecked
getConnectionStatus, isConnectionOpened
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
readDatagrams
public AbstractPrefetchInputStreamReceiver()
AbstractPrefetchInputStreamReceiver
.public AbstractPrefetchInputStreamReceiver(ExecutorService aExecutorService)
AbstractPrefetchInputStreamReceiver
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 AbstractPrefetchInputStreamReceiver(int aQueueCapacity)
AbstractPrefetchInputStreamReceiver
using the given
datagram queue capacity.aQueueCapacity
- The capacity of the prefetch queue before it blocks
until data is read via AbstractReceiver.readDatagram()
(
AbstractReceiver.readDatagrams()
).public AbstractPrefetchInputStreamReceiver(int aQueueCapacity, ExecutorService aExecutorService)
AbstractPrefetchInputStreamReceiver
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 AbstractReceiver.readDatagram()
(
AbstractReceiver.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 AbstractReceiver<DATA extends Serializable>
org.refcodes.component.CloseException
protected void open(InputStream aInputStream) throws org.refcodes.component.OpenException
ConnectionOpenable.open(Object)
.aInputStream
- the input streamorg.refcodes.component.OpenException
- the open exceptionprotected boolean isOpenable(InputStream aInputStream)
ConnectionOpenable.ConnectionOpenAutomaton.isOpenable(Object)
.aInputStream
- the input streamCopyright © 2018. All rights reserved.