@@ -51,7 +51,7 @@ public class Select {
5151 * <p>If no clauses are given, throws {@link ChannelDoneException}.
5252 *
5353 * @param clauses The clauses, from which one will be selected. Array must not be empty or
54- * {@code null} and can't contain {@code null} values.
54+ * {@code null} and can't contain {@code null} values.
5555 * @return The value returned by the selected clause.
5656 * @throws ChannelClosedException When any of the channels is closed (done or in error).
5757 */
@@ -76,9 +76,9 @@ public static <U> U select(SelectClause<? extends U>... clauses) throws Interrup
7676 * <p>If no clauses are given, returns {@link ChannelDone}.
7777 *
7878 * @param clauses The clauses, from which one will be selected. Array must not be empty or
79- * {@code null} and can't contain {@code null} values.
79+ * {@code null} and can't contain {@code null} values.
8080 * @return Either the value returned by the selected clause, or {@link ChannelClosed}, when any
81- * of the channels is closed (done or in error).
81+ * of the channels is closed (done or in error).
8282 */
8383 @ SafeVarargs
8484 public static <U > Object selectOrClosed (SelectClause <? extends U >... clauses )
@@ -122,9 +122,9 @@ public static <U> Object selectOrClosed(SelectClause<? extends U>... clauses)
122122 *
123123 * @param timeout The maximum time to wait for a clause to be selected.
124124 * @param clauses The clauses, from which one will be selected. Array must not be empty or
125- * {@code null} and can't contain {@code null} values.
125+ * {@code null} and can't contain {@code null} values.
126126 * @return The value returned by the selected clause.
127- * @throws TimeoutException When the timeout elapses before any clause can be selected.
127+ * @throws TimeoutException When the timeout elapses before any clause can be selected.
128128 * @throws InterruptedException When the current thread is interrupted.
129129 */
130130 @ SafeVarargs
@@ -154,12 +154,12 @@ public static <U> U selectWithin(Duration timeout, SelectClause<? extends U>...
154154 *
155155 * <p>If the timeout elapses before any clause can be completed, returns the timeout value.
156156 *
157- * @param timeout The maximum time to wait for a clause to be selected.
157+ * @param timeout The maximum time to wait for a clause to be selected.
158158 * @param timeoutValue The value to return if the timeout elapses.
159- * @param clauses The clauses, from which one will be selected. Array must not be empty or
160- * {@code null} and can't contain {@code null} values.
159+ * @param clauses The clauses, from which one will be selected. Array must not be empty or
160+ * {@code null} and can't contain {@code null} values.
161161 * @return Either the value returned by the selected clause, the timeout value when timeout
162- * occurs, or {@link ChannelClosed} when any of the channels is closed (done or in error).
162+ * occurs, or {@link ChannelClosed} when any of the channels is closed (done or in error).
163163 * @throws InterruptedException When the current thread is interrupted.
164164 */
165165 @ SafeVarargs
@@ -221,9 +221,8 @@ private static void joinUninterruptibly(Thread thread) throws InterruptedExcepti
221221 private static <U > Object doSelectOrClosed (SelectClause <? extends U >... clauses )
222222 throws InterruptedException {
223223 // short-circuiting if any of the channels is in error; otherwise, we might have selected a
224- // clause, for which
225- // a value was available immediately - even though a channel for a clause appearing later
226- // was in error
224+ // clause, for which a value was available immediately - even though a channel for a clause
225+ // appearing later was in error
227226 var anyError = getAnyChannelInError (clauses );
228227 if (anyError != null ) {
229228 return anyError ;
@@ -290,9 +289,15 @@ public static <T> SelectClause<T> defaultClause(Supplier<T> callback) {
290289
291290class SelectInstance {
292291 /**
293- * Possible states: - one of {@link SelectState} - {@link Thread} to wake up - {@link
294- * ChannelClosed} - a {@link List} of clauses to re-register - when selected, {@link
295- * SelectClause} (during registration) or {@link StoredSelectClause} (with suspension)
292+ * Possible states:
293+ * <ul>
294+ * <li>one of {@link SelectState}</li>
295+ * <li>{@link Thread} to wake up</li>
296+ * <li>{@link ChannelClosed}</li>
297+ * <li>a {@link List} of clauses to re-register - when selected</li>
298+ * <li>{@link SelectClause} (during registration)</li>
299+ * <li>{@link StoredSelectClause} (with suspension)</li>
300+ * </ul>
296301 */
297302 private volatile Object state = SelectState .REGISTERING ;
298303
@@ -331,7 +336,7 @@ class SelectInstance {
331336 * registered.
332337 *
333338 * @return {@code true}, if the registration was successful, and the clause has been stored.
334- * {@code false}, if the channel is closed, or the clause has been immediately selected.
339+ * {@code false}, if the channel is closed, or the clause has been immediately selected.
335340 */
336341 @ SuppressWarnings ("BooleanMethodIsAlwaysInverted" )
337342 <U > boolean register (SelectClause <U > clause ) {
@@ -365,18 +370,17 @@ <U> boolean register(SelectClause<U> clause) {
365370
366371 /**
367372 * @param allRendezvous If channels for all clauses are rendezvous channels. In such a case,
368- * busy-looping is initially used, instead of blocking.
373+ * busy-looping is initially used, instead of blocking.
369374 * @return Either the value returned by the selected clause (which can include {@link
370- * RestartSelectMarker#RESTART}), or {@link ChannelClosed}, when any of the channels is
371- * closed.
375+ * RestartSelectMarker#RESTART}), or {@link ChannelClosed}, when any of the channels is
376+ * closed.
372377 */
373378 Object checkStateAndWait (boolean allRendezvous ) throws InterruptedException {
374379 while (true ) {
375380 var currentState = state ;
376381 if (currentState == SelectState .REGISTERING ) {
377382 // registering done, waiting until a clause is selected - setting the thread to wake
378- // up as the state
379- // we won't leave this case until the state is changed from Thread
383+ // up as the state we won't leave this case until the state is changed from Thread
380384 var currentThread = Thread .currentThread ();
381385 if (STATE .compareAndSet (this , SelectState .REGISTERING , currentThread )) {
382386 var spinIterations = allRendezvous ? Continuation .RENDEZVOUS_SPINS : 0 ;
@@ -397,8 +401,8 @@ Object checkStateAndWait(boolean allRendezvous) throws InterruptedException {
397401 throw new InterruptedException ();
398402 } else {
399403 // another thread already changed the state; setting the
400- // interrupt status (so that
401- // the next blocking operation throws), and continuing
404+ // interrupt status (so that the next blocking operation
405+ // throws), and continuing
402406 Thread .currentThread ().interrupt ();
403407 }
404408 }
@@ -426,8 +430,8 @@ Object checkStateAndWait(boolean allRendezvous) throws InterruptedException {
426430
427431 if (!register (clause )) {
428432 // channel is closed, or clause was selected - in both cases, no point
429- // in further
430- // re-registrations; the state should be appropriately updated
433+ // in further re-registrations; the state should be appropriately
434+ // updated
431435 break ;
432436 }
433437 }
@@ -475,8 +479,8 @@ private void cleanup(SelectClause<?> selected) {
475479
476480 /**
477481 * @return {@code true} if the given clause was successfully selected, {@code false} otherwise
478- * (a channel is closed, another clause is selected, registration is in progress, select is
479- * interrupted).
482+ * (a channel is closed, another clause is selected, registration is in progress, select is
483+ * interrupted).
480484 */
481485 boolean trySelect (StoredSelectClause storedSelectClause ) {
482486 while (true ) {
@@ -527,8 +531,8 @@ boolean trySelect(StoredSelectClause storedSelectClause) {
527531
528532 /**
529533 * @return {@code true} when the given {@code channelClosed} has been set as the new state of
530- * the select. {@code false}, if another clause has already been selected, or if the channel
531- * is already closed.
534+ * the select. {@code false}, if another clause has already been selected, or if the channel
535+ * is already closed.
532536 */
533537 boolean channelClosed (ChannelClosed channelClosed ) {
534538 while (true ) {
0 commit comments