public class Selector<Message> extends java.lang.Object implements Synchronization
| Modifier and Type | Method and Description |
|---|---|
SelectAction<?> |
getWinner() |
static <Message> SelectAction<Message> |
receive(ReceivePort<? extends Message> ch)
Creates a
SelectAction for a receive operation |
static <Message> SelectAction<Message> |
receive(ReceivePort<? extends Message> ch,
SelectReceiveListener<Message> listener)
Creates a
SelectAction for a receive operation |
java.lang.Object |
register() |
static <Message> SelectAction<Message> |
select(boolean priority,
java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes.
|
static <Message> SelectAction<Message> |
select(boolean priority,
long timeout,
java.util.concurrent.TimeUnit unit,
java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the specified timeout.
|
static <Message> SelectAction<Message> |
select(boolean priority,
long timeout,
java.util.concurrent.TimeUnit unit,
SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
select(boolean priority,
SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes.
|
static <Message> SelectAction<Message> |
select(boolean priority,
Timeout timeout,
java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the specified timeout.
|
static <Message> SelectAction<Message> |
select(boolean priority,
Timeout timeout,
SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
select(java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes.
|
static <Message> SelectAction<Message> |
select(long timeout,
java.util.concurrent.TimeUnit unit,
java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
select(long timeout,
java.util.concurrent.TimeUnit unit,
SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
select(SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes.
|
static <Message> SelectAction<Message> |
select(Timeout timeout,
java.util.List<? extends SelectAction<Message>> actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
select(Timeout timeout,
SelectAction<Message>... actions)
Performs exactly one channel operation of a given set, blocking until any of the actions completes, but no longer than the given timeout.
|
static <Message> SelectAction<Message> |
send(SendPort<? super Message> ch,
Message message)
Creates a
SelectAction for a send operation |
static <Message> SelectAction<Message> |
send(SendPort<? super Message> ch,
Message message,
SelectSendListener<Message> listener)
Creates a
SelectAction for a send operation |
java.lang.String |
toString() |
SelectAction<Message> |
trySelect() |
static <Message> SelectAction<Message> |
trySelect(boolean priority,
java.util.List<? extends SelectAction<Message>> actions)
Attempts to performs exactly one channel operation of a given set if one can be completed without blocking.
|
static <Message> SelectAction<Message> |
trySelect(boolean priority,
SelectAction<Message>... actions)
Attempts to performs exactly one channel operation of a given set if one can be completed without blocking.
|
static <Message> SelectAction<Message> |
trySelect(java.util.List<? extends SelectAction<Message>> actions)
Attempts to performs exactly one channel operation of a given set if one can be completed without blocking.
|
static <Message> SelectAction<Message> |
trySelect(SelectAction<Message>... actions)
Attempts to performs exactly one channel operation of a given set if one can be completed without blocking.
|
void |
unregister(java.lang.Object registrationToken) |
public static <Message> SelectAction<Message> select(boolean priority, SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(boolean priority, long timeout, java.util.concurrent.TimeUnit unit, SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.timeout - the maximum duration to block waiting for an operation to complete.unit - the time unit of the given timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(boolean priority, Timeout timeout, SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.timeout - the method will not block for longer than the amount remaining in the Timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(boolean priority, java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(boolean priority, long timeout, java.util.concurrent.TimeUnit unit, java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
timeout - the maximum duration to block waiting for an operation to complete.unit - the time unit of the given timeoutpriority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(boolean priority, Timeout timeout, java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
timeout - the method will not block for longer than the amount remaining in the Timeoutpriority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
select(false, actions).actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(long timeout, java.util.concurrent.TimeUnit unit, SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
select(false, timeout, unit, actions).timeout - the maximum duration to block waiting for an operation to complete.unit - the time unit of the given timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(Timeout timeout, SelectAction<Message>... actions) throws java.lang.InterruptedException, SuspendExecution
select(false, timeout, unit, actions).timeout - the method will not block for longer than the amount remaining in the Timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
select(false, actions).actions - a list of actions, one of which will be performed.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(long timeout, java.util.concurrent.TimeUnit unit, java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
select(false, timeout, unit, actions).timeout - the maximum duration to block waiting for an operation to complete.unit - the time unit of the given timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> select(Timeout timeout, java.util.List<? extends SelectAction<Message>> actions) throws java.lang.InterruptedException, SuspendExecution
select(false, timeout, unit, actions).timeout - the method will not block for longer than the amount remaining in the Timeoutactions - a list of actions, one of which will be performed.null if the timeout expired before an operation could complete.java.lang.InterruptedExceptionSuspendExecutionpublic static <Message> SelectAction<Message> trySelect(boolean priority, SelectAction<Message>... actions) throws SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.SuspendExecutionpublic static <Message> SelectAction<Message> trySelect(boolean priority, java.util.List<? extends SelectAction<Message>> actions) throws SuspendExecution
priority - If true and more than one operation can complete at the same time, the one that appears in the given list first will be the one performed.
If false the order of the operations is ignored.actions - a list of actions, one of which will be performed.SuspendExecutionpublic static <Message> SelectAction<Message> trySelect(SelectAction<Message>... actions) throws SuspendExecution
trySelect(false, actions).actions - a list of actions, one of which will be performed.SuspendExecutionpublic static <Message> SelectAction<Message> trySelect(java.util.List<? extends SelectAction<Message>> actions) throws SuspendExecution
trySelect(false, actions).actions - a list of actions, one of which will be performed.SuspendExecutionpublic static <Message> SelectAction<Message> send(SendPort<? super Message> ch, Message message)
SelectAction for a send operationMessage - ch - The channel to which the operation tries to send the messagemessage - the message to send.SelectAction that can be selected by the selector.public static <Message> SelectAction<Message> send(SendPort<? super Message> ch, Message message, SelectSendListener<Message> listener)
SelectAction for a send operationMessage - ch - The channel to which the operation tries to send the messagemessage - the message to send.listener - a SelectSendListener which will be triggered if this operation succeeds.SelectAction that can be selected by the selector.public static <Message> SelectAction<Message> receive(ReceivePort<? extends Message> ch)
SelectAction for a receive operationMessage - ch - the channel from which the operation tries to receiveSelectAction that can be selected by the selector.public static <Message> SelectAction<Message> receive(ReceivePort<? extends Message> ch, SelectReceiveListener<Message> listener)
SelectAction for a receive operationMessage - ch - the channel from which the operation tries to receivelistener - a SelectReceiveListener which will be triggered if this operation succeeds.SelectAction that can be selected by the selector.public java.lang.Object register()
register in interface Synchronizationpublic void unregister(java.lang.Object registrationToken)
unregister in interface Synchronizationpublic SelectAction<Message> trySelect() throws SuspendExecution
SuspendExecutionpublic SelectAction<?> getWinner()
public java.lang.String toString()
toString in class java.lang.Object