```val channel = Channel<ByteArray>(capacity = 10 ...
# coroutines
u
Copy code
val channel = Channel<ByteArray>(capacity = 10 <---------, onBufferOverflow = DROP_OLDEST)
launch {
    while (isActive) {
        val bytes = queryMicrophone()
        channel.send(bytes)
    }
    channel.close()
}
How can I tweak the capacity empiraclly what effectively is a ring buffer? I.e. I need to analyze if the overflow behavior happened, which is undesirable in my case. (It can happen but should not for ideal UX => increase buffer size) is there some sort of
channel.isFull
I can check before `send`ing?
y
By tweaking it empirically, do you mean at runtime? Or do you mean you'll do some testing and figure out how often the buffer is full?
There is a
onUndeliveredElement
parameter that should help with your testing. It's called on every dropped element I believe, so you can count how often that happens and adjust the size accordingly
u
yes only for testing purposes, for the capacity to not be a total gut feeling
I see, thanks!