You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using channel with any buffer size, after filling full buffer with some elements, and then sending even more (those calls will suspend), after receiving first value from buffer, on first element, where send suspends, onUndeliveredElement will be called, and after next receive, onUndeliveredElement will be called on next element and so on, so calling onUndeliveredElement on all elements, that overflow buffer.
Reproducer:
classResource(vali:Int) {
var closed =falseoverridefuntoString(): String="Resource($i, closed=$closed)"
}
@Test
funtestChannel() = test { //promise on js, runBlocking on jvmval channel =Channel<Resource>(3) {
println("CLOSE: $it")
it.closed =true
}
val job = launch {
repeat(6) {
println("RECEIVE - ${channel.receive()}")
}
}
(0..5).map {
val r =Resource(it)
async {
println("SEND: $r")
channel.send(r)
println("SENT: $r")
}
}.awaitAll()
job.join()
}
When using channel with any buffer size, after filling full buffer with some elements, and then sending even more (those calls will suspend), after receiving first value from buffer, on first element, where
send
suspends,onUndeliveredElement
will be called, and after next receive,onUndeliveredElement
will be called on next element and so on, so callingonUndeliveredElement
on all elements, that overflow buffer.Reproducer:
JVM/Native output - expected:
JS (same for browser/node legacy/IR) output - wrong:
Expected result:
There should be no calls to
onUndeliveredElement
in such caseEnv:
kotlinVersion=1.5.21
kotlinxCoroutinesVersion=1.5.1-native-mt
The text was updated successfully, but these errors were encountered: