Class ChannelSelect.Result

java.lang.Object
groovy.concurrent.ChannelSelect.Result
Enclosing class:
ChannelSelect

public static final class ChannelSelect.Result extends Object
The result of a ChannelSelect.select() operation, indicating which offer committed.
Since:
6.0.0
  • Method Details

    • getIndex

      public int getIndex()
      The zero-based index of the offer that committed.
    • getChannel

      public AsyncChannel<?> 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 is null: a select that carries a timer offer and dispatches on the channel must test isTimeout() first, and dereference the channel only when that is false.
      Returns:
      the winning channel, or null for 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; the Instant it 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 by ChannelSelect.after(long): the select timed out, and getValue() is the instant at which it did.
      Since:
      6.0.0
    • toString

      public String toString()
      Returns a diagnostic representation of this selection result.
      Overrides:
      toString in class Object
      Returns:
      the selection result description