efemoney
10/13/2024, 12:11 PMchannelFlow
wrapper with one extra internal channel that is buffered.
Out of order items are sent to the buffered channel until I reach the in-order items.
At a certain point, I then want to emit all the buffered items and afterwards continue to emit the rest of the incoming events.
I tried
channelWithBufferedItems.consumeEach {
channel.send(it)
}
but that doesn’t work because it iterates the buffered channel but afterwards suspends the consumeEach waiting for new itemsefemoney
10/13/2024, 12:13 PMbuffered.consume {
while (!isEmpty) channel.send(receive())
}
efemoney
10/13/2024, 12:16 PMisEmpty
will return true in cases where receive()
would’ve suspended so its good for terminating the loop & cancelling the channel afterZach Klippenstein (he/him) [MOD]
10/13/2024, 4:22 PMtryReceive
Zach Klippenstein (he/him) [MOD]
10/13/2024, 4:33 PMefemoney
10/13/2024, 5:25 PM