bufferCapacity

Configures how many advertisements may be buffered while waiting to be collected.

Scan results are never delivered by blocking the (Android provided) thread that scan callbacks are invoked from, so this capacity — rather than backpressure — is what absorbs a collector slower than scan results arrive:

  • UNLIMITED (the default) buffers without bound, so no scan results are dropped.

  • Any capacity of at least 1 drops the oldest buffered scan result to make room for the newest. A capacity of 1 is equivalent to applying the conflate flow operator on the advertisements property.

Channel.BUFFERED and Channel.CONFLATED are rejected, as neither keeps its usual meaning once the oldest buffered scan result is dropped on overflow: Channel.BUFFERED would silently behave as a capacity of 1 rather than the default channel capacity, and Channel.CONFLATED cannot be combined with an overflow strategy at all.

See https://github.com/JuulLabs/kable/issues/654 for more details.