@@ -373,7 +373,7 @@ internal open class SelectImplementation<R>(
373
373
/* *
374
374
* List of clauses waiting on this `select` instance.
375
375
*
376
- * This property is the subject to bening data- race: concurrent cancellation might null-out this property
376
+ * This property is the subject to bening data race: concurrent cancellation might null-out this property
377
377
* while [trySelect] operation reads it and iterates over its content.
378
378
* A logical race is resolved by the consensus on [state] property.
379
379
*/
@@ -412,8 +412,13 @@ internal open class SelectImplementation<R>(
412
412
* one that stores either result when the clause is successfully registered ([inRegistrationPhase] is `true`),
413
413
* or [DisposableHandle] instance when the clause is completed during registration ([inRegistrationPhase] is `false`).
414
414
* Yet, this optimization is omitted for code simplicity.
415
+ *
416
+ * This property is the subject to benign data race:
417
+ * [Cleanup][cleanup] procedure can be invoked both as part of the completion sequence
418
+ * and as a cancellation handler triggered by an external cancellation.
419
+ * In both scenarios, [NO_RESULT] is written to this property via race.
415
420
*/
416
- @BenignDataRace // See its cleanup phase for the explanation
421
+ @BenignDataRace
417
422
private var internalResult: Any? = NO_RESULT
418
423
419
424
/* *
@@ -627,10 +632,7 @@ internal open class SelectImplementation<R>(
627
632
// try to resume the continuation.
628
633
this .internalResult = internalResult
629
634
if (cont.tryResume(onCancellation)) return TRY_SELECT_SUCCESSFUL
630
- /*
631
- * If the resumption failed, we need to clean the [result] field to avoid memory leaks.
632
- * This write is benignly races with the very same write in cancellation invoke() handler
633
- */
635
+ // If the resumption failed, we need to clean the [result] field to avoid memory leaks.
634
636
this .internalResult = NO_RESULT
635
637
return TRY_SELECT_CANCELLED
636
638
}
0 commit comments