Skip to content

feat(channel): implement channel taxonomy - #183

Closed
tisonkun wants to merge 1 commit into
mainfrom
codex/channel-terminal
Closed

feat(channel): implement channel taxonomy#183
tisonkun wants to merge 1 commit into
mainfrom
codex/channel-terminal

Conversation

@tisonkun

@tisonkun tisonkun commented Aug 23, 2026

Copy link
Copy Markdown
Member

Closes #167. Supersedes #117.

Summary

  • Keep direct public paths such as asyncband::mpsc, asyncband::spmc, and asyncband::broadcast, while collecting their implementations in a private channel source tree.
  • Preserve the existing oneshot and MPSC APIs and algorithms; add bounded and unbounded SPSC, SPMC, and MPMC competing queues, lossless SPMC and MPMC broadcast channels, and a latest-state watch channel.
  • Encode topology in nominal endpoint types: only the endpoints that support multiple producers or competing consumers are cloneable.
  • Keep bounded and unbounded semantics explicit. Bounded channels apply backpressure without dropping accepted values; sliding/drop-oldest and lag semantics remain deferred.

Design Notes

  • This supersedes the earlier unbounded broadcast work in feat(broadcast): add unbounded MPMC channel #117. Its implementation is not carried over, while Orthur's contribution is retained through the feature commit's Co-authored-by trailer.
  • MPSC retains the current AtomicWaker receiver path from main, and SPSC reuses that backend. Multi-consumer queues and broadcasts use WaitSet because they must track multiple pending receivers.
  • Broadcast is a lossless retained log gated by the slowest live subscription. Its dense cursor registry makes reclamation proportional to current fanout rather than historical subscription high-water.
  • User value drops, clones, and wakeups occur outside internal locks. Disruptor/ring and power-of-two constraints stay internal and out of the public API; no current channel semantics require them.
  • Latest representative medians from cargo x bench: MPSC unbounded 9.79 ns, MPMC queue unbounded 8.81 ns, SPSC queue unbounded 9.78 ns, broadcast unbounded with one subscription 28.58 ns, and watch send-and-borrow 15.56 ns. Broadcast reclamation with 256 historical subscriptions and one live subscription was 32.81 ns.
  • Validated with cargo x lint, cargo x test, cargo x check, cargo x bench, and cargo +1.86.0 check -p asyncband --all-features --all-targets.

@tisonkun
tisonkun force-pushed the codex/channel-terminal branch from 941c8df to 8e1f1f8 Compare August 24, 2026 03:37
@tisonkun
tisonkun marked this pull request as draft August 24, 2026 04:00
@tisonkun
tisonkun force-pushed the codex/channel-terminal branch from 8e1f1f8 to 27510c7 Compare August 26, 2026 06:06
@tisonkun tisonkun changed the title feat(channel): implement the terminal channel taxonomy feat(channel): implement channel taxonomy Aug 26, 2026
Co-authored-by: Orthur <orthur2@gmail.com>
@tisonkun
tisonkun force-pushed the codex/channel-terminal branch from 27510c7 to a45ba6d Compare August 26, 2026 15:18
@tisonkun

Copy link
Copy Markdown
Member Author

Closing this bundled implementation in favor of an incremental rollout.

The channel work is now tracked by #206 through independently reviewable sub-issues. The replacement starts with #207, which only moves the existing oneshot and MPSC implementations into the terminal private source layout without changing algorithms or adding channel families.

@tisonkun

Copy link
Copy Markdown
Member Author

The focused replacement for the first step is now #217. It only establishes the private source layout for the existing oneshot and MPSC implementations and closes #207.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

design(channel): organize channel families and capacity contracts

1 participant