java.lang.Object
com.softwaremill.jox.Select
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SelectClause<T> defaultClause(Supplier<T> callback) static <T> SelectClause<T> defaultClause(T value) static <U> Uselect(SelectClause<? extends U>... clauses) Select exactly one clause to complete.static <U> ObjectselectOrClosed(SelectClause<? extends U>... clauses) Select exactly one clause to complete.
-
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 ornulland can't containnullvalues.- 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 ornulland can't containnullvalues.- 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
-
defaultClause
-