@@ -1992,6 +1992,29 @@ internal open class BufferedChannel<E>(
1992
1992
return lastSegment
1993
1993
}
1994
1994
1995
+ /* *
1996
+ * Completes the channel cancellation procedure.
1997
+ */
1998
+ private fun completeCancel (sendersCur : Long ) {
1999
+ // First, ensure that this channel is closed,
2000
+ // obtaining the last segment in the linked list.
2001
+ val lastSegment = completeClose(sendersCur)
2002
+ // Cancel suspended `send(e)` requests and
2003
+ // remove buffered elements in the reverse order.
2004
+ removeUnprocessedElements(lastSegment)
2005
+ }
2006
+
2007
+ /* *
2008
+ * Closes the underlying linked list of segments for further segment addition.
2009
+ */
2010
+ private fun closeLinkedList (): ChannelSegment <E > {
2011
+ // Choose the last segment.
2012
+ val lastSegment = listOf (bufferEndSegment.value, sendSegment.value, receiveSegment.value).maxBy { it.id }
2013
+ // Close the linked list of segment for new segment addition
2014
+ // and return the last segment in the linked list.
2015
+ return lastSegment.close()
2016
+ }
2017
+
1995
2018
/* *
1996
2019
* This function marks all empty cells, in the `null` and [IN_BUFFER] state,
1997
2020
* as closed. Notably, it processes the cells from right to left, and finishes
@@ -2033,29 +2056,6 @@ internal open class BufferedChannel<E>(
2033
2056
}
2034
2057
}
2035
2058
2036
- /* *
2037
- * Completes the channel cancellation procedure.
2038
- */
2039
- private fun completeCancel (sendersCur : Long ) {
2040
- // First, ensure that this channel is closed,
2041
- // obtaining the last segment in the linked list.
2042
- val lastSegment = completeClose(sendersCur)
2043
- // Cancel suspended `send(e)` requests and
2044
- // remove buffered elements in the reverse order.
2045
- removeUnprocessedElements(lastSegment)
2046
- }
2047
-
2048
- /* *
2049
- * Closes the underlying linked list of segments for further segment addition.
2050
- */
2051
- private fun closeLinkedList (): ChannelSegment <E > {
2052
- // Choose the last segment.
2053
- val lastSegment = listOf (bufferEndSegment.value, sendSegment.value, receiveSegment.value).maxBy { it.id }
2054
- // Close the linked list of segment for new segment addition
2055
- // and return the last segment in the linked list.
2056
- return lastSegment.close()
2057
- }
2058
-
2059
2059
/* *
2060
2060
* Cancels suspended `send(e)` requests and removes buffered elements
2061
2061
* starting from the last cell in the specified [lastSegment] (it must
0 commit comments