Package groovy.concurrent
Class ChannelSelect.Result
java.lang.Object
groovy.concurrent.ChannelSelect.Result
- Enclosing class:
- ChannelSelect
The result of a
ChannelSelect.select() operation, indicating which
offer committed.- Since:
- 6.0.0
-
Method Summary
Modifier and TypeMethodDescriptionAsyncChannel<?>The channel the committed offer transferred over: the one received from, or the one sent to.intgetIndex()The zero-based index of the offer that committed.<T> TgetValue()The transferred value: what arrived, for a receive offer; what was sent, for a send offer; theInstantit fired, for a timer offer.booleanisSend()Whether the committed offer was a send (an output guard).booleanWhether the committed offer was a timer created byChannelSelect.after(long): the select timed out, andgetValue()is the instant at which it did.toString()Returns a diagnostic representation of this selection result.
-
Method Details
-
getIndex
public int getIndex()The zero-based index of the offer that committed. -
getChannel
The channel the committed offer transferred over: the one received from, or the one sent to. Lets a branch be recognised by identity rather than by position, which suits a select whose offers are assembled dynamically. A timer offer transfers over no channel of the caller's, so for a timeout this isnull: a select that carries a timer offer and dispatches on the channel must testisTimeout()first, and dereference the channel only when that isfalse.- Returns:
- the winning channel, or
nullfor a timeout - Since:
- 6.0.0
- See Also:
-
getValue
public <T> T getValue()The transferred value: what arrived, for a receive offer; what was sent, for a send offer; theInstantit fired, for a timer offer. -
isSend
public boolean isSend()Whether the committed offer was a send (an output guard).- Since:
- 6.0.0
-
isTimeout
public boolean isTimeout()Whether the committed offer was a timer created byChannelSelect.after(long): the select timed out, andgetValue()is the instant at which it did.- Since:
- 6.0.0
-
toString
Returns a diagnostic representation of this selection result.
-