Skip to content

feat(broadcast): add unbounded policy#117

Draft
orthur2 wants to merge 2 commits into
fast:mainfrom
orthur2:feat/broadcast-unbounded
Draft

feat(broadcast): add unbounded policy#117
orthur2 wants to merge 2 commits into
fast:mainfrom
orthur2:feat/broadcast-unbounded

Conversation

@orthur2

@orthur2 orthur2 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR implements the unbounded policy proposed in #95. Messages remain in the shared buffer until every active receiver has consumed them, or until receivers that have not consumed them are dropped. The channel has no capacity limit, so receivers do not lag and the receive error type has no Lagged variant.

The WaitSet cleanup needed by Recv::Drop was handled separately in #116. This PR is based on that change and focuses on the unbounded policy.

The channel uses a single Mutex to protect the VecDeque<Arc> buffer and the Slab containing receiver cursors. It also tracks how many receivers are at the current buffer head. When the last receiver at the head advances or is dropped, the channel finds the new minimum cursor and removes the corresponding messages. Removed values are dropped after releasing the lock.

Messages are stored as Arc internally, while recv returns a cloned T, so callers do not need to use Arc themselves. subscribe and resubscribe both create a receiver at the current tail without changing the backlog of existing receivers. Message versions use u64, and send panics if the version counter overflows.

By the way, I will update this branch if the WaitSet design changes.

Refs #95. Based on #116.

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.

1 participant