public class AsyncReceive<T> extends Object implements AsyncStoppable
Receives messages asynchronously. One or more Receive instances can use used as a source of messages. Messages are sent to a Dispatch
It is also possible to specify an onReceiversExhausted Runnable callback that will be run when all of the given receivers
have been exhausted of messages. However, the current implementation is flawed in that this may erroneously fire if the first receiver
is exhausted before the second starts.
| Constructor and Description |
|---|
AsyncReceive(Executor executor) |
AsyncReceive(Executor executor,
Dispatch<? super T> dispatch) |
AsyncReceive(Executor executor,
Dispatch<? super T> dispatch,
Runnable onReceiversExhausted) |
AsyncReceive(Executor executor,
Runnable onReceiversExhausted) |
| Modifier and Type | Method and Description |
|---|---|
void |
dispatchTo(Dispatch<? super T> dispatch)
Starts dispatching to the given dispatch.
|
void |
receiveFrom(Receive<? extends T> receive)
Starts receiving from the given receive.
|
void |
requestStop()
Stops receiving new messages.
|
void |
stop()
Stops receiving new messages.
|
public AsyncReceive(Executor executor)
public void dispatchTo(Dispatch<? super T> dispatch)
public void receiveFrom(Receive<? extends T> receive)
public void requestStop()
requestStop in interface AsyncStoppableCopyright © 2013. All rights reserved