File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/selects Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -360,7 +360,15 @@ internal class SelectBuilderImpl<in R>(
360
360
@JvmField val desc : AtomicDesc ,
361
361
@JvmField val select : Boolean
362
362
) : AtomicOp<Any?>() {
363
- override fun prepare (affected : Any? ): Any? = prepareIfNotSelected() ? : desc.prepare(this )
363
+ override fun prepare (affected : Any? ): Any? {
364
+ // only originator of operation makes preparation move of installing descriptor into this selector's state
365
+ // helpers should never do it, or risk ruining progress when they come late
366
+ if (affected == null ) {
367
+ // we are originator (affected reference is not null if helping)
368
+ prepareIfNotSelected()?.let { return it }
369
+ }
370
+ return desc.prepare(this )
371
+ }
364
372
365
373
override fun complete (affected : Any? , failure : Any? ) {
366
374
completeSelect(failure)
You can’t perform that action at this time.
0 commit comments