public class EagerReceiveBuffer<T> extends Object implements Receive<T>, AsyncStoppable
Messages from the same receive instance are guaranteed to always be returned from receive() in sequence. However, no
guarantee is made to deliver messages from different sources in chronological order when multiple multiple receive instances
are being consumed from.
The buffer is bounded, the size of which is specified at construction or defaulting to . If the buffer fills, the receive threads will block until space becomes available. If a stop is initiated while a thread is waiting for free space in the buffer after having received a message, that message will be discarded.
If a stop is initiated while a receive thread is waiting to receive (i.e. is blocked in a receive() call to the source),
the stop will block until this returns. Therefore, it is advised to try to externally stop each of the receive instances being
used by the buffer before initiating a stop on the buffer.
| Constructor and Description |
|---|
EagerReceiveBuffer(StoppableExecutor executor,
Collection<Receive<T>> receivers) |
EagerReceiveBuffer(StoppableExecutor executor,
Collection<Receive<T>> receivers,
Runnable onReceiversExhausted) |
EagerReceiveBuffer(StoppableExecutor executor,
int bufferSize,
Collection<Receive<T>> receivers) |
EagerReceiveBuffer(StoppableExecutor executor,
int bufferSize,
Collection<Receive<T>> receivers,
Runnable onReceiversExhausted) |
EagerReceiveBuffer(StoppableExecutor executor,
int bufferSize,
Receive<T> receiver) |
EagerReceiveBuffer(StoppableExecutor executor,
int bufferSize,
Receive<T> receiver,
Runnable onReceiversExhausted) |
EagerReceiveBuffer(StoppableExecutor executor,
Receive<T> receiver) |
EagerReceiveBuffer(StoppableExecutor executor,
Receive<T> receiver,
Runnable onReceiversExhausted) |
| Modifier and Type | Method and Description |
|---|---|
T |
receive()
Receive the next message from the buffer.
|
void |
requestStop()
Stops receiving new messages.
|
void |
start()
Start consuming from the receivers given at construction.
|
void |
stop()
Stops receiving new messages.
|
public EagerReceiveBuffer(StoppableExecutor executor, Receive<T> receiver)
public EagerReceiveBuffer(StoppableExecutor executor, Receive<T> receiver, Runnable onReceiversExhausted)
public EagerReceiveBuffer(StoppableExecutor executor, Collection<Receive<T>> receivers)
public EagerReceiveBuffer(StoppableExecutor executor, Collection<Receive<T>> receivers, Runnable onReceiversExhausted)
public EagerReceiveBuffer(StoppableExecutor executor, int bufferSize, Receive<T> receiver)
public EagerReceiveBuffer(StoppableExecutor executor, int bufferSize, Receive<T> receiver, Runnable onReceiversExhausted)
public EagerReceiveBuffer(StoppableExecutor executor, int bufferSize, Collection<Receive<T>> receivers)
public EagerReceiveBuffer(StoppableExecutor executor, int bufferSize, Collection<Receive<T>> receivers, Runnable onReceiversExhausted)
public void start()
IllegalStateException - if already startedpublic T receive()
public void requestStop()
requestStop in interface AsyncStoppableCopyright © 2013. All rights reserved