Skip to content

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.

2 participants