public class ReceivePortGroup<M> extends java.lang.Object implements Mix<M>
Mix.Mode, Mix.SoloEffect, Mix.StateReceivePort.EOFException| Constructor and Description |
|---|
ReceivePortGroup() |
ReceivePortGroup(boolean alwaysOpen) |
ReceivePortGroup(java.util.Collection<? extends ReceivePort<? extends M>> ports) |
ReceivePortGroup(java.util.Collection<? extends ReceivePort<? extends M>> ports,
boolean alwaysOpen) |
ReceivePortGroup(ReceivePort<? extends M>... ports) |
| Modifier and Type | Method and Description |
|---|---|
<T extends ReceivePort<? extends M>> |
add(T... items) |
void |
close()
Closes the channel so that no more messages could be sent to it.
|
Mix.SoloEffect |
getSoloEffect() |
<T extends ReceivePort<? extends M>> |
getState(T... items) |
boolean |
isClosed()
Tests whether the channel has been closed and no more messages await in the channel.
|
M |
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.
|
M |
receive(long timeout,
java.util.concurrent.TimeUnit unit)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
|
M |
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
|
<T extends ReceivePort<? extends M>> |
remove(T... items) |
void |
setSoloEffect(Mix.SoloEffect effect) |
<T extends ReceivePort<? extends M>> |
setState(java.util.Map<T,Mix.State> newStates) |
<T extends ReceivePort<? extends M>> |
setState(Mix.State state,
T... items) |
M |
tryReceive()
Retrieves a message from the channel if one is available.
|
public ReceivePortGroup(java.util.Collection<? extends ReceivePort<? extends M>> ports, boolean alwaysOpen)
public ReceivePortGroup(java.util.Collection<? extends ReceivePort<? extends M>> ports)
public ReceivePortGroup(ReceivePort<? extends M>... ports)
public ReceivePortGroup(boolean alwaysOpen)
public ReceivePortGroup()
public M tryReceive()
ReceivePorttryReceive in interface ReceivePort<M>null if one is not immediately available.public M receive() throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<M>null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()).java.lang.InterruptedExceptionSuspendExecutionpublic M receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<M>timeout - the method will not block for longer than the amount remaining in the Timeoutnull if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.java.lang.InterruptedExceptionSuspendExecutionpublic M receive(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, SuspendExecution
ReceivePortreceive in interface ReceivePort<M>timeout - the maximum duration to block waiting for a message.unit - the time unit of the timeout.null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.java.lang.InterruptedExceptionSuspendExecutionpublic void close()
PortAutoCloseableclose in interface PortAutoCloseableclose in interface java.lang.AutoCloseablepublic boolean isClosed()
PortAutoCloseabletrue all
future calls to receive are guaranteed to return null, and calls to receive on a primitive channel
will throw a EOFException.isClosed in interface PortAutoCloseabletrue if the channels has been closed and no more messages will be received; false otherwise.public <T extends ReceivePort<? extends M>> void add(T... items) throws SuspendExecution, java.lang.InterruptedException
add in interface Mix<M>SuspendExecutionjava.lang.InterruptedExceptionpublic <T extends ReceivePort<? extends M>> void remove(T... items) throws SuspendExecution, java.lang.InterruptedException
remove in interface Mix<M>items - If null or empty, all items will be removed.SuspendExecutionjava.lang.InterruptedExceptionpublic <T extends ReceivePort<? extends M>> java.util.Map<T,Mix.State> getState(T... items)
public <T extends ReceivePort<? extends M>> void setState(Mix.State state, T... items) throws SuspendExecution, java.lang.InterruptedException
setState in interface Mix<M>items - If null or empty, all items state will be set to state.SuspendExecutionjava.lang.InterruptedExceptionpublic <T extends ReceivePort<? extends M>> void setState(java.util.Map<T,Mix.State> newStates) throws SuspendExecution, java.lang.InterruptedException
setState in interface Mix<M>SuspendExecutionjava.lang.InterruptedExceptionpublic Mix.SoloEffect getSoloEffect()
getSoloEffect in interface Mix<M>public void setSoloEffect(Mix.SoloEffect effect) throws SuspendExecution, java.lang.InterruptedException
setSoloEffect in interface Mix<M>SuspendExecutionjava.lang.InterruptedException