Skip to content

Conversation

@martin-g
Copy link
Member

Motivation

tokio::sync::broadcast::Sender::closed() should return Poll::Ready if there are no receivers for the channel.
A newly created Sender with Sender::new() currently returns Poll::Pending although there are no receivers for it.

Solution

Initialize Tail::closed with receivers_count == 0

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Sep 18, 2025
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 added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Sep 18, 2025
@martin-g martin-g force-pushed the broadcast-sender-new-closed-true branch 2 times, most recently from 6a9bf27 to 3d3b8f4 Compare September 19, 2025 06:45
Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

@martin-g Could you sync the changes from the base branch to fix the CI failures?

…closed

Sender::closed() should return Poll::Ready() if there are no receivers
for this channel
@martin-g martin-g force-pushed the broadcast-sender-new-closed-true branch from 3d3b8f4 to 6398d6e Compare September 20, 2025 05:59
Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

Thanks!

@ADD-SP ADD-SP changed the title sync: Newly created broadcast::Sender without any receiver should be closed sync: set the receiver count correctly in broadcast::Sender::new() Sep 20, 2025
@ADD-SP ADD-SP changed the title sync: set the receiver count correctly in broadcast::Sender::new() sync: close the broadcast::Sender by default in broadcast::Sender::new() Sep 20, 2025
@ADD-SP ADD-SP changed the title sync: close the broadcast::Sender by default in broadcast::Sender::new() sync: close the broadcast::Sender in broadcast::Sender::new() Sep 20, 2025
@ADD-SP ADD-SP merged commit 6d1ae62 into tokio-rs:master Sep 20, 2025
89 checks passed
@martin-g martin-g deleted the broadcast-sender-new-closed-true branch September 20, 2025 06:55
@Darksonn Darksonn mentioned this pull request Oct 14, 2025
@ADD-SP ADD-SP mentioned this pull request Oct 14, 2025
ADD-SP pushed a commit to ADD-SP/tokio that referenced this pull request Oct 14, 2025
ADD-SP pushed a commit to ADD-SP/tokio that referenced this pull request Oct 14, 2025
ADD-SP pushed a commit to ADD-SP/tokio that referenced this pull request Oct 14, 2025
@ADD-SP ADD-SP mentioned this pull request Oct 14, 2025
ADD-SP pushed a commit that referenced this pull request Oct 14, 2025
@ADD-SP ADD-SP mentioned this pull request Oct 14, 2025
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.

3 participants