@@ -651,7 +651,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
651
651
}
652
652
653
653
@Suppress(" UNCHECKED_CAST" )
654
- public final override suspend fun receiveOrClosed (): ReceiveResult <E > {
654
+ public final override suspend fun receiveOrClosed (): ValueOrClosed <E > {
655
655
// fast path -- try poll non-blocking
656
656
val result = pollInternal()
657
657
if (result != = POLL_FAILED ) {
@@ -662,7 +662,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
662
662
}
663
663
664
664
@Suppress(" UNCHECKED_CAST" )
665
- private suspend fun receiveOrClosedSuspend (): ReceiveResult <E > = suspendAtomicCancellableCoroutine(holdCancellability = true ) sc@{ cont ->
665
+ private suspend fun receiveOrClosedSuspend (): ValueOrClosed <E > = suspendAtomicCancellableCoroutine(holdCancellability = true ) sc@{ cont ->
666
666
val receive = ReceiveElement <E >(cont as CancellableContinuation <Any ?>, ResumeMode .RECEIVE_RESULT )
667
667
while (true ) {
668
668
if (enqueueReceive(receive)) {
@@ -827,15 +827,15 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
827
827
}
828
828
}
829
829
830
- override val onReceiveOrClosed: SelectClause1 <ReceiveResult <E >>
831
- get() = object : SelectClause1 <ReceiveResult <E >> {
832
- override fun <R > registerSelectClause1 (select : SelectInstance <R >, block : suspend (ReceiveResult <E >) -> R ) {
830
+ override val onReceiveOrClosed: SelectClause1 <ValueOrClosed <E >>
831
+ get() = object : SelectClause1 <ValueOrClosed <E >> {
832
+ override fun <R > registerSelectClause1 (select : SelectInstance <R >, block : suspend (ValueOrClosed <E >) -> R ) {
833
833
registerSelectReceiveOrClosed(select, block)
834
834
}
835
835
}
836
836
837
837
@Suppress(" UNCHECKED_CAST" )
838
- private fun <R > registerSelectReceiveOrClosed (select : SelectInstance <R >, block : suspend (ReceiveResult <E >) -> R ) {
838
+ private fun <R > registerSelectReceiveOrClosed (select : SelectInstance <R >, block : suspend (ValueOrClosed <E >) -> R ) {
839
839
while (true ) {
840
840
if (select.isSelected) return
841
841
if (isEmpty) {
@@ -846,11 +846,11 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
846
846
pollResult == = ALREADY_SELECTED -> return
847
847
pollResult == = POLL_FAILED -> {} // retry
848
848
pollResult is Closed <* > -> {
849
- block.startCoroutineUnintercepted(ReceiveResult .closed(pollResult.receiveException), select.completion)
849
+ block.startCoroutineUnintercepted(ValueOrClosed .closed(pollResult.receiveException), select.completion)
850
850
}
851
851
else -> {
852
852
// selected successfully
853
- block.startCoroutineUnintercepted(ReceiveResult .value(pollResult as E ), select.completion)
853
+ block.startCoroutineUnintercepted(ValueOrClosed .value(pollResult as E ), select.completion)
854
854
return
855
855
}
856
856
}
@@ -970,7 +970,7 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
970
970
@Suppress(" IMPLICIT_CAST_TO_ANY" )
971
971
override fun tryResumeReceive (value : E , idempotent : Any? ): Any? {
972
972
val resumeValue = when (resumeMode) {
973
- ResumeMode .RECEIVE_RESULT -> ReceiveResult .value(value)
973
+ ResumeMode .RECEIVE_RESULT -> ValueOrClosed .value(value)
974
974
else -> value
975
975
}
976
976
return cont.tryResume(resumeValue, idempotent)
@@ -1041,15 +1041,15 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
1041
1041
@Suppress(" UNCHECKED_CAST" )
1042
1042
override fun completeResumeReceive (token : Any ) {
1043
1043
val value: E = (if (token == = NULL_VALUE ) null else token) as E
1044
- block.startCoroutine(if (mode == ResumeMode .RECEIVE_RESULT ) ReceiveResult .value(value) else value, select.completion)
1044
+ block.startCoroutine(if (mode == ResumeMode .RECEIVE_RESULT ) ValueOrClosed .value(value) else value, select.completion)
1045
1045
}
1046
1046
1047
1047
override fun resumeReceiveClosed (closed : Closed <* >) {
1048
1048
if (! select.trySelect(null )) return
1049
1049
1050
1050
when (mode) {
1051
1051
ResumeMode .THROW_ON_CLOSE -> select.resumeSelectCancellableWithException(closed.receiveException)
1052
- ResumeMode .RECEIVE_RESULT -> block.startCoroutine(ReceiveResult .closed<R >(closed.receiveException), select.completion)
1052
+ ResumeMode .RECEIVE_RESULT -> block.startCoroutine(ValueOrClosed .closed<R >(closed.receiveException), select.completion)
1053
1053
ResumeMode .NULL_ON_CLOSE -> if (closed.closeCause == null ) {
1054
1054
block.startCoroutine(null , select.completion)
1055
1055
} else {
@@ -1161,11 +1161,11 @@ private abstract class Receive<in E> : LockFreeLinkedListNode(), ReceiveOrClosed
1161
1161
}
1162
1162
1163
1163
@Suppress(" NOTHING_TO_INLINE" , " UNCHECKED_CAST" )
1164
- private inline fun <E > Any?.toResult (): ReceiveResult <E > =
1165
- if (this is Closed <* >) ReceiveResult .closed(receiveException) else ReceiveResult .value(this as E )
1164
+ private inline fun <E > Any?.toResult (): ValueOrClosed <E > =
1165
+ if (this is Closed <* >) ValueOrClosed .closed(receiveException) else ValueOrClosed .value(this as E )
1166
1166
1167
1167
@Suppress(" NOTHING_TO_INLINE" )
1168
- private inline fun <E > Closed <* >.toResult (): ReceiveResult <E > = ReceiveResult .closed(receiveException)
1168
+ private inline fun <E > Closed <* >.toResult (): ValueOrClosed <E > = ValueOrClosed .closed(receiveException)
1169
1169
1170
1170
// Marker for receive, receiveOrNull and receiveOrClosed
1171
1171
private enum class ResumeMode {
0 commit comments