Class Select

java.lang.Object
com.softwaremill.jox.Select

public class Select extends Object
  • Constructor Details

    • Select

      public Select()
  • Method Details

    • select

      @SafeVarargs public static <U> U select(SelectClause<? extends U>... clauses) throws InterruptedException
      Select exactly one clause to complete. Each clause should be created for a different channel.

      If a couple of the clauses can be completed immediately, the select is biased towards the clauses that appear first.

      If no clauses are given, throws ChannelDoneException.

      Parameters:
      clauses - The clauses, from which one will be selected. Array must not be empty or null and can't contain null values.
      Returns:
      The value returned by the selected clause.
      Throws:
      ChannelClosedException - When any of the channels is closed (done or in error).
      InterruptedException
    • selectOrClosed

      @SafeVarargs public static <U> Object selectOrClosed(SelectClause<? extends U>... clauses) throws InterruptedException
      Select exactly one clause to complete. Each clause should be created for a different channel. Doesn't throw exceptions when the channel is closed, but returns a value.

      If a couple of the clauses can be completed immediately, the select is biased towards the clauses that appear first.

      If no clauses are given, returns ChannelDone.

      Parameters:
      clauses - The clauses, from which one will be selected. Array must not be empty or null and can't contain null values.
      Returns:
      Either the value returned by the selected clause, or ChannelClosed, when any of the channels is closed (done or in error).
      Throws:
      InterruptedException
    • defaultClause

      public static <T> SelectClause<T> defaultClause(T value)
    • defaultClause

      public static <T> SelectClause<T> defaultClause(Supplier<T> callback)