You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zhiqiangxu
changed the title
x/sync: semaphore.Weighted.Acquire should try to notify other waiters
x/sync: semaphore.Weighted.Acquire should try to notify other waiters when canceled
Mar 14, 2020
When
Release
, if the remaining tokens are not enough for the front waiter, no waiters will be notified.So if the canceled waiter is the front one, it should try to notify following waiters if there are remaining tokens.
I found this bug when implementing a cancelable rwmutex based on semaphore:
https://github.com/zhiqiangxu/util/blob/master/mutex/crwmutex.go
This bug can be verified by this test:
https://github.com/zhiqiangxu/util/blob/master/mutex/crwmutex_test.go#L43
I've submitted a PR here: golang/sync#10
The text was updated successfully, but these errors were encountered: