|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.Select
@SuppressWarnings({"MethodNamesDifferingOnlyByCase"}) public class Select extends java.lang.Object
A Select allows the user to select a value from multiple channels, which have a value available for read at the moment. It can either pick a channel randomly, when using the plain select method, or with precedence towards channels with lower position indexes, when the prioritySelect method is used. If a value is not available immediately in any of the channels, Select will wait for the first value to arrive in any of the channels.
Both 'select' and 'prioritySelect' methods come in two flavours - blocking, which wait till a value is available in a channel, and messaging, which send out a message to the specified message handler, as soon as a message is available. Optionally, all methods allow the user to specify a boolean mask, assigning each select 's input channel a flag indicating, whether it should be included in the select operation. This is useful when handling state to selectively block some inputs in some states.Field Summary | |
---|---|
private SelectBase |
selectBase
|
Constructor Summary | |
Select(PGroup pGroup, DataflowReadChannel channels)
@param pGroup The group, the thread pool of which should be used for notification message handlers |
|
Select(PGroup pGroup, java.util.List channels)
@param pGroup The group, the thread pool of which should be used for notification message handlers |
Method Summary | |
---|---|
SelectResult
|
call()
Selects a value from a single randomly chosen input channel, which has a value available for read. |
SelectResult
|
call(java.util.List mask)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
void
|
call(MessageStream messageStream)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
void
|
call(MessageStream messageStream, java.util.List mask)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
SelectResult
|
prioritySelect()
Selects a value from a single input channel, which has a value available for read. |
SelectResult
|
prioritySelect(java.util.List mask)
Selects a value from a single input channel, which has a value available for read. |
void
|
prioritySelect(MessageStream messageStream)
Selects a value from a single input channel, which has a value available for read. |
void
|
prioritySelect(MessageStream messageStream, java.util.List mask)
Selects a value from a single input channel, which has a value available for read. |
SelectResult
|
select()
Selects a value from a single randomly chosen input channel, which has a value available for read. |
SelectResult
|
select(java.util.List mask)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
void
|
select(MessageStream messageStream)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
void
|
select(MessageStream messageStream, java.util.List mask)
Selects a value from a single randomly chosen input channel, which has a value available for read. |
private void
|
select(MessageStream messageStream, int startIndex, java.util.List mask)
Invokes the internal select base with a SelectRequest instance ensuring a message is sent, once a value has been selected |
private SelectResult
|
select(int startIndex, java.util.List mask)
Invokes the internal select base with a SelectRequest instance ensuring the current thread can continue returning the correct value, once a value has been selected |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
private final SelectBase selectBase
Constructor Detail |
---|
@SuppressWarnings({"OverloadedVarargsMethod"}) public Select(PGroup pGroup, DataflowReadChannel channels)
pGroup
- The group, the thread pool of which should be used for notification message handlerschannels
- The input channels to select from
public Select(PGroup pGroup, java.util.List channels)
pGroup
- The group, the thread pool of which should be used for notification message handlerschannels
- The list of input channels to select from
Method Detail |
---|
public final SelectResult call()
public final SelectResult call(java.util.List mask)
mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
public final void call(MessageStream messageStream)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.
public final void call(MessageStream messageStream, java.util.List mask)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
public SelectResult prioritySelect()
public SelectResult prioritySelect(java.util.List mask)
mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
public void prioritySelect(MessageStream messageStream)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.
public void prioritySelect(MessageStream messageStream, java.util.List mask)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
public SelectResult select()
public SelectResult select(java.util.List mask)
mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
public void select(MessageStream messageStream)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.
public void select(MessageStream messageStream, java.util.List mask)
messageStream
- A message stream accepting the selected value. The message will be of SelectResult type, holding the actual value as well as the channel index.mask
- A list of boolean values indicating, whether the input channel with the same position index should be included in the selection or not
private void select(MessageStream messageStream, int startIndex, java.util.List mask)
private SelectResult select(int startIndex, java.util.List mask)
Copyright © 2008–2010 Václav Pech. All Rights Reserved.