Skip to content

Commit be39731

Browse files
committed
Calling a function containing atomic operations from a different file results in the failure of Native incremental compilation.
Made BufferedChannel#sendImpl function private. This is a WA for KT-65554
1 parent 761bdeb commit be39731

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

kotlinx-coroutines-core/common/src/channels/BufferedChannel.kt

+23-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ internal open class BufferedChannel<E>(
241241
/**
242242
* Abstract send implementation.
243243
*/
244-
protected inline fun <R> sendImpl(
244+
private inline fun <R> sendImpl(
245245
/* The element to be sent. */
246246
element: E,
247247
/* The waiter to be stored in case of suspension,
@@ -350,6 +350,27 @@ internal open class BufferedChannel<E>(
350350
}
351351
}
352352

353+
protected fun trySendDropOldest(element: E): ChannelResult<Unit> =
354+
sendImpl( // <-- this is an inline function
355+
element = element,
356+
// Put the element into the logical buffer even
357+
// if this channel is already full, the `onSuspend`
358+
// callback below extract the first (oldest) element.
359+
waiter = BUFFERED,
360+
// Finish successfully when a rendezvous has happened
361+
// or the element has been buffered.
362+
onRendezvousOrBuffered = { return success(Unit) },
363+
// In case the algorithm decided to suspend, the element
364+
// was added to the buffer. However, as the buffer is now
365+
// overflowed, the first (oldest) element has to be extracted.
366+
onSuspend = { segm, i ->
367+
dropFirstElementUntilTheSpecifiedCellIsInTheBuffer(segm.id * SEGMENT_SIZE + i)
368+
return success(Unit)
369+
},
370+
// If the channel is closed, return the corresponding result.
371+
onClosed = { return closed(sendException) }
372+
)
373+
353374
private inline fun sendImplOnNoWaiter(
354375
/* The working cell is specified by
355376
the segment and the index in it. */
@@ -1587,7 +1608,7 @@ internal open class BufferedChannel<E>(
15871608
* It is nulled-out on both completion and cancellation paths that
15881609
* could happen concurrently.
15891610
*/
1590-
@BenignDataRace
1611+
//@BenignDataRace
15911612
private var continuation: CancellableContinuationImpl<Boolean>? = null
15921613

15931614
// `hasNext()` is just a special receive operation.

kotlinx-coroutines-core/common/src/channels/ConflatedBufferedChannel.kt

-21
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,6 @@ internal open class ConflatedBufferedChannel<E>(
7272
return success(Unit)
7373
}
7474

75-
private fun trySendDropOldest(element: E): ChannelResult<Unit> =
76-
sendImpl( // <-- this is an inline function
77-
element = element,
78-
// Put the element into the logical buffer even
79-
// if this channel is already full, the `onSuspend`
80-
// callback below extract the first (oldest) element.
81-
waiter = BUFFERED,
82-
// Finish successfully when a rendezvous has happened
83-
// or the element has been buffered.
84-
onRendezvousOrBuffered = { return success(Unit) },
85-
// In case the algorithm decided to suspend, the element
86-
// was added to the buffer. However, as the buffer is now
87-
// overflowed, the first (oldest) element has to be extracted.
88-
onSuspend = { segm, i ->
89-
dropFirstElementUntilTheSpecifiedCellIsInTheBuffer(segm.id * SEGMENT_SIZE + i)
90-
return success(Unit)
91-
},
92-
// If the channel is closed, return the corresponding result.
93-
onClosed = { return closed(sendException) }
94-
)
95-
9675
@Suppress("UNCHECKED_CAST")
9776
override fun registerSelectForSend(select: SelectInstance<*>, element: Any?) {
9877
// The plain `send(..)` operation never suspends. Thus, either this

0 commit comments

Comments
 (0)