Is there a way to find number of elements in kotlin channel

955 views Asked by At

I am using a Channel because I needed a non-blocking queue. I also want to maintain certain number of elements in the queue by prefetching (to avoid fetch-after-going-empty) so that there are elements always present when needed.

To trigger prefetching, I need to know if the size has fallen below a threshold. However, I do not see any .size() method on Kotlin Channel or ReceiveChannel. There is an experiment api .isEmpty() though.

Is expecting size() here is anti-pattern?

0

There are 0 answers