/claim #9810
Fix ZStream.buffer(n) so the requested capacity matches the actual number of elements that can be prefetched.
buffer(1) now uses a synchronous handoff path, so the producer cannot start a third element before the consumer asks for the secondbuffer(n) for n > 1 uses an internal queue capacity of n - 1, which preserves exactly n total in-flight elements when combined with the consumer’s current elementbuffer(1) and buffer(2) distinctionRan:
sbt -Dsbt.supershell=false "streamsTestsJVM/testOnly zio.stream.ZStreamSpec -- -t buffer"
Result: 22 tests passed, 0 failed.
If this bounty is rewarded, please attribute payout to @hriszc via the Algora account linked to this GitHub identity.
This keeps the change local to ZStream.buffer rather than redesigning queue internals. It also follows the discussion on the issue that buffer(1) is the special case requiring synchronous handoff semantics.
hriszc
@hriszc
ZIO
@ZIO