-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Expose semaphore's MAX_PERMITS as a public constant. #5129
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Comments
This seems reasonable enough. |
vi
added a commit
to vi/tokio
that referenced
this issue
Oct 29, 2022
vi
added a commit
to vi/tokio
that referenced
this issue
Oct 29, 2022
vi
added a commit
to vi/tokio
that referenced
this issue
Oct 29, 2022
vi
added a commit
to vi/tokio
that referenced
this issue
Oct 30, 2022
Add and adjust some tests. Adjust related documentation. Resolves tokio-rs#5129
vi
added a commit
to vi/tokio
that referenced
this issue
Oct 30, 2022
Add and adjust some tests. Adjust related documentation. Resolves tokio-rs#5129
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
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Is your feature request related to a problem? Please describe.
Sometimes semaphore needs to be disabled at runtime by adjusting it's configuration. But obvious
usize::MAX
fails witha semaphore may not have more than MAX_PERMITS permits (2305843009213693951)
panic.But
MAX_PERMITS
mentioned in the panic message is not available in API. Apart from serving as "effective infinity", it may be used to filter user input, preventing causing panics by setting deliberately invalid value. How are apps supposed to check user-configurable concurrency limit without panicking?Describe the solution you'd like
pub const tokio::sync::Semaphore::MAX_PERMITS: usize = ...;
Describe alternatives you've considered
2305843009213693951
explicitly as a limit and never shrinking it, so apps can safely embed it.The text was updated successfully, but these errors were encountered: