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

feat: impl forget exactly #37

Merged
merged 4 commits into from
Feb 13, 2025
Merged

feat: impl forget exactly #37

merged 4 commits into from
Feb 13, 2025

Conversation

tisonkun
Copy link
Collaborator

@tisonkun tisonkun commented Feb 12, 2025

Good for "resize" a semaphore.

From deadpool-rs/deadpool#147 (comment):

I implement a similar function today at #37 while notice that this try_acquire + forget can have a race condition to accidentally add available permits.

For example, there are pending semaphore.acquire()s inside timeout_get, and now a user call resize. try_acquire can return NoPermits because the pending acquires consume all available permits now. Then the less "total permits" of the semaphore gets reduced, causing the "total permits" larger than slots.max_size.

@tisonkun tisonkun requested a review from andylokandy February 12, 2025 23:47
@tisonkun tisonkun merged commit e204d4b into main Feb 13, 2025
9 checks passed
@tisonkun tisonkun deleted the forget-exactly branch February 13, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant