Skip to content

Conversation

tabokie
Copy link

@tabokie tabokie commented Sep 23, 2025

Motivation

A panic condition is not documented.

Solution

Document it.

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Sep 23, 2025
@tabokie tabokie changed the title clarify bounded channel panic behavior sync: clarify bounded channel panic behavior Sep 23, 2025
@tabokie tabokie force-pushed the xinye/channel-panic branch from 7a387b4 to f1322a8 Compare September 23, 2025 03:19
@tabokie tabokie force-pushed the xinye/channel-panic branch from f1322a8 to f6d85f0 Compare September 23, 2025 05:12
@ADD-SP ADD-SP added T-docs Topic: documentation A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Sep 23, 2025
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.

Could you mention the panic behavior about Semaphore::MAX_PERMITS might be changed in the future and downstream should not rely on it.

Although it is unlikely to change the implementation of mpsc in the future, I still don't want to make the downstream relies on it, it should not be the part of semver.

@ADD-SP ADD-SP added the S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author. label Sep 23, 2025
@tabokie
Copy link
Author

tabokie commented Sep 25, 2025

If I understand correct, referencing a public constant in library (instead of advertising the exact value) implies the constant may change and does prevent the compatibility risk you mentioned? (E.g. that's the way semaphore is documented: https://docs.rs/tokio/latest/tokio/sync/struct.Semaphore.html#method.new)

If however you meant the dependency between mpsc and Semaphore might change in the future and that poses a risk, then we should re-export the constant (mpsc::MAX_CAPACITY = Semaphore::MAX_PERMITS)?

might be changed in the future

okay with this addition,

downstream should not rely on it

but this is probably not how I perceive it.

@ADD-SP
Copy link
Member

ADD-SP commented Sep 25, 2025

If however you meant the dependency between mpsc and Semaphore might change in the future and that poses a risk, then we should re-export the constant (mpsc::MAX_CAPACITY = Semaphore::MAX_PERMITS)?

We are not inclined to introduce a new thing into the tokio crate unless absolutely necessary. Since it is not a common case to set the capacity of mpsc to 2_305_843_009_213_693_951usize, I prefer just write document to mention the current behavior and claim it is not the part of the semver.

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 S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author. T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants