mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00

## Motivation The `tokio::sync::Semaphore` type provides a [`Semaphore::available_permits` method][1] which returns the current number of permits available on the semaphore. `tokio_util::sync::PollSemaphore` [does not expose such a method][2]. It is possible to use `PollSemaphore::into_inner` or `PollSemaphore::clone_inner` to unwrap the inner semaphore, but this may require cloning/dropping the semaphore's `Arc` which shouldn't be necessary to access the permits. ## Solution This commit adds `PollSemaphore::available_permits`. It also adds `PollSemaphore::add_permits` and an `AsRef<Semaphore>` impl while we're here. [1]: https://docs.rs/tokio/1.4.0/tokio/sync/struct.Semaphore.html#method.available_permits [2]: https://docs.rs/tokio-util/0.6.5/tokio_util/sync/struct.PollSemaphore.html#implementations Closes #3682
tokio-util
Utilities for encoding and decoding frames.
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.