/claim #9844

Summary

This PR adds shutdownCause(cause: Cause[Nothing]) support to Queue and propagates the selected shutdown cause consistently to pending and future queue operations.

What changed

  • Added shutdownCause(cause: Cause[Nothing]) to Enqueue and Dequeue.
  • Implemented Queue.shutdownCause with first-wins semantics via AtomicReference[Cause[Nothing]].
  • Updated Queue.shutdown to delegate to shutdownCause(Cause.interrupt(fiberId)) to preserve current behavior.
  • Propagated the shutdown cause to:
    • pending takers
    • pending backpressured putters
    • future queue operations (offer*, take*, poll, size)
  • Added forwarding implementations where required by the new API:
    • Hub / hub subscription wrappers (delegate to existing shutdown behavior)
    • ZStream.mapDequeue wrapper

Compatibility

This keeps existing shutdown behavior intact and avoids adding an extra type parameter to Queue, while enabling explicit cause propagation through shutdownCause.

Tests

Added focused tests in QueueSpec:

  • shutdownCause with take fiber
  • shutdownCause with offer fiber
  • shutdownCause applies to future queue operations
  • shutdownCause preserves first cause

Validated with:

SBT_OPTS='-Xms1G -Xmx3G -Xss4M -XX:+UseG1GC' sbt "coreTestsJVM/testOnly zio.QueueSpec -- -t shutdownCause"
SBT_OPTS='-Xms1G -Xmx3G -Xss4M -XX:+UseG1GC' sbt "coreTestsJVM/testOnly zio.QueueSpec -- -t shutdown"

Claim

Total prize pool $100
Total paid $0
Status Pending
Submitted March 03, 2026
Last updated March 03, 2026

Contributors

LI

Liuyi Yu

@yuliuyi717-ux

100%

Sponsors

ZI

ZIO

@ZIO

$100