@@ -382,15 +382,11 @@ internal abstract class AbstractSendChannel<E> : SendChannel<E> {
382
382
select.disposeOnSelect(node)
383
383
return
384
384
}
385
- enqueueResult is Closed <* > -> {
386
- node.block.shareableDispose(useIt = true )
387
- throw recoverStackTrace(helpCloseAndGetSendException(enqueueResult))
388
- }
385
+ enqueueResult is Closed <* > -> throw recoverStackTrace(helpCloseAndGetSendException(enqueueResult))
389
386
enqueueResult == = ENQUEUE_FAILED -> {} // try to offer
390
387
enqueueResult is Receive <* > -> {} // try to offer
391
388
else -> error(" enqueueSend returned $enqueueResult " )
392
389
}
393
- node.block.shareableDispose(useIt = true )
394
390
}
395
391
// hm... receiver is waiting or buffer is not full. try to offer
396
392
val offerResult = offerSelectInternal(element, select)
@@ -457,14 +453,13 @@ internal abstract class AbstractSendChannel<E> : SendChannel<E> {
457
453
@JvmField val block: suspend (SendChannel <E >) -> R = block.asShareable()
458
454
459
455
override fun tryResumeSend (otherOp : PrepareOp ? ): Symbol ? =
460
- select.trySelectOther(otherOp, onSelect = block::shareableWillBeUsed ) as Symbol ? // must return symbol
456
+ select.trySelectOther(otherOp) as Symbol ? // must return symbol
461
457
462
458
override fun completeResumeSend () {
463
459
startCoroutine(CoroutineStart .ATOMIC , channel, select.completion, block)
464
460
}
465
461
466
462
override fun dispose () { // invoked on select completion
467
- block.shareableDispose(useIt = false )
468
463
remove()
469
464
}
470
465
@@ -780,11 +775,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
780
775
): Boolean {
781
776
val node = ReceiveSelect (this , select, block, receiveMode)
782
777
val result = enqueueReceive(node)
783
- if (result) {
784
- select.disposeOnSelect(node)
785
- } else {
786
- node.block.shareableDispose(useIt = true )
787
- }
778
+ if (result) select.disposeOnSelect(node)
788
779
return result
789
780
}
790
781
@@ -963,32 +954,27 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
963
954
@JvmField val block: suspend (Any? ) -> R = block.asShareable() // captured variables in this block need screening
964
955
965
956
override fun tryResumeReceive (value : E , otherOp : PrepareOp ? ): Symbol ? =
966
- select.trySelectOther(otherOp, onSelect = block::shareableWillBeUsed ) as Symbol ?
957
+ select.trySelectOther(otherOp) as Symbol ?
967
958
968
959
@Suppress(" UNCHECKED_CAST" )
969
960
override fun completeResumeReceive (value : E ) {
970
961
startCoroutine(CoroutineStart .ATOMIC , if (receiveMode == RECEIVE_RESULT ) ValueOrClosed .value(value) else value, select.completion, block)
971
962
}
972
963
973
964
override fun resumeReceiveClosed (closed : Closed <* >) {
974
- if (! select.trySelect(onSelect = block::shareableWillBeUsed )) return
965
+ if (! select.trySelect()) return
975
966
when (receiveMode) {
976
- RECEIVE_THROWS_ON_CLOSE -> {
977
- block.shareableDispose(useIt = true )
978
- select.resumeSelectWithException(closed.receiveException)
979
- }
967
+ RECEIVE_THROWS_ON_CLOSE -> select.resumeSelectWithException(closed.receiveException)
980
968
RECEIVE_RESULT -> startCoroutine(CoroutineStart .ATOMIC , ValueOrClosed .closed<R >(closed.closeCause), select.completion, block)
981
969
RECEIVE_NULL_ON_CLOSE -> if (closed.closeCause == null ) {
982
970
startCoroutine(CoroutineStart .ATOMIC , null , select.completion, block)
983
971
} else {
984
- block.shareableDispose(useIt = true )
985
972
select.resumeSelectWithException(closed.receiveException)
986
973
}
987
974
}
988
975
}
989
976
990
977
override fun dispose () { // invoked on select completion
991
- block.shareableDispose(useIt = false )
992
978
if (remove())
993
979
channel.onReceiveDequeued() // notify cancellation of receive
994
980
}
0 commit comments