@@ -2512,8 +2512,8 @@ internal open class BufferedChannel<E>(
2512
2512
This method is used in the physical removal of the segment. It helps to move pointers forward from
2513
2513
the segment which was physically removed.
2514
2514
*/
2515
- internal fun movePointersForwardFrom (from : ChannelSegment <E >) {
2516
- check( from.isRemoved) { " Trying to move channel pointers from the alive segment. " }
2515
+ internal fun movePointersForwardFromRemovedSegment (from : ChannelSegment <E >) {
2516
+ if ( ! from.isRemoved) return
2517
2517
if (from == sendSegment.value) sendSegment.moveToSpecifiedOrLast(from.id, from)
2518
2518
if (from == receiveSegment.value) receiveSegment.moveToSpecifiedOrLast(from.id, from)
2519
2519
if (from == bufferEndSegment.value) bufferEndSegment.moveToSpecifiedOrLast(from.id, from)
@@ -2785,13 +2785,13 @@ internal class ChannelSegment<E>(id: Long, prev: ChannelSegment<E>?, channel: Bu
2785
2785
/* *
2786
2786
* Removes the segment physically from the segment list.
2787
2787
*
2788
- * If the physical removal was successful and there are channel pointers pointing on this segment,
2789
- * the [BufferedChannel.movePointersForwardFrom ] method is invoked to move them further on the segment list.
2788
+ * After the physical removal is finished and there are channel pointers referencing the removed segment,
2789
+ * the [BufferedChannel.movePointersForwardFromRemovedSegment ] method is invoked to move them further on the segment list.
2790
2790
*/
2791
- override fun remove (): Boolean =
2792
- super .remove(). also {
2793
- if (it) channel.movePointersForwardFrom (this )
2794
- }
2791
+ override fun remove () {
2792
+ super .remove()
2793
+ channel.movePointersForwardFromRemovedSegment (this )
2794
+ }
2795
2795
2796
2796
// ########################
2797
2797
// # Cancellation Support #
0 commit comments