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

tokio-sync: add acquire_many and try_acquire_many methods to Sempahore #3067

Merged
merged 1 commit into from Nov 10, 2020

Conversation

dcarrier
Copy link
Contributor

@dcarrier dcarrier commented Oct 28, 2020

Fixes: #1550

Motivation

Add support for acquiring multiple permits on the Sempahore public api.

Solution

I changed the permits field type from u16 to u32 on Semaphore and OwnedSemaphorePermit to match the batch_semaphore lower level implementation which was introduced with #2607.

I added acquire_many and try_acquire_many methods to the Semaphore to add multiple permit acquisition functionality. I believe that these new methods have test coverage by the existing batch_semaphore tests.

@dcarrier dcarrier changed the title tokio-sync: add acquire_many and try_acquire_many methods to Sempahore tokio-sync: add acquire_many and try_acquire_many methods to Sempahore Oct 28, 2020
@Darksonn Darksonn added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync labels Oct 29, 2020
@Darksonn Darksonn requested a review from hawkw October 31, 2020 09:32
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

LGTM thanks.

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-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio-sync: Acquire n permits from a semaphore
3 participants