Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Added WeakSender to sync::broadcast::channel #7100

Merged
merged 4 commits into from
Feb 17, 2025

Conversation

tglane
Copy link
Contributor

@tglane tglane commented Jan 14, 2025

Motivation

Closing issue #7003. Add a type WeakSender to the sync::broadcast::channel similar to sync::maps::channel.

Solution

The new WeakSender type just stores an Arc<Shared<T>> just like the normal Sender but active WeakSenders will not prevent the channel from being closed if all Senders are dropped.

Closes #7003.

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Jan 14, 2025
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Jan 27, 2025
* Changed memory orderings of `num_weak_tx`: Increments happen with relaxed, decrements happen with acqrel and checks for zero happen with acquire.
* Add asserts for `sync::broadcast::WeakSender` to
  `tests/async_send_sync.rs`
@tglane tglane requested a review from Darksonn February 5, 2025 18:30
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Darksonn Darksonn merged commit 4380c3d into tokio-rs:master Feb 17, 2025
83 checks passed
@Carter12s
Copy link

Just want to say as the original requester of this feature THANK YOU!

Frankly awesome to see how quickly this feature request was supported, y'all rock!

@tglane
Copy link
Contributor Author

tglane commented Feb 19, 2025

Just want to say as the original requester of this feature THANK YOU!

Frankly awesome to see how quickly this feature request was supported, y'all rock!

I'm always looking for some issues I can work on after work to help out. Great to help you with this one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync R-loom-sync Run loom sync tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WeakSender for tokio::sync::broadcast
3 participants