Skip to content

Commit 7c1391a

Browse files
committed
fix documentation
1 parent 00dfe57 commit 7c1391a

File tree

1 file changed

+3
-1
lines changed
  • kotlinx-coroutines-core/common/src/selects

1 file changed

+3
-1
lines changed

kotlinx-coroutines-core/common/src/selects/Select.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ internal open class SelectImplementation<R> constructor(
569569
when (val curState = state.value) {
570570
// Perform a rendezvous with this select if it is in WAITING state.
571571
is CancellableContinuation<*> -> {
572-
val clause = findClause(clauseObject) ?: continue
572+
val clause = findClause(clauseObject) ?: continue // retry if `clauses` is already `null`
573573
val onCancellation = clause.createOnCancellationAction(this@SelectImplementation, internalResult)
574574
if (state.compareAndSet(curState, clause)) {
575575
@Suppress("UNCHECKED_CAST")
@@ -604,6 +604,8 @@ internal open class SelectImplementation<R> constructor(
604604

605605
/**
606606
* Finds the clause with the corresponding [clause object][SelectClause.clauseObject].
607+
* If the reference to the list of clauses is already cleared due to completion/cancellation,
608+
* this function returns `null`
607609
*/
608610
private fun findClause(clauseObject: Any) = clauses?.run {
609611
find { it.clauseObject === clauseObject } ?: error("Clause with object $clauseObject is not found")

0 commit comments

Comments
 (0)