-
Notifications
You must be signed in to change notification settings - Fork 4
Description
The phrasing of the spurious failure case of semaphore try_acquire can confuse readers, who may parse it as being about blocking guarantees or a statement about QoI, rather than capturing various memory model subtleties as intended. Better would be to word this case similarly to mutex try_lock. The proposed change does so.
Proposed change:
Replace with "Effects: Attempts to atomically check if the counter is positive and decrement it by one if so, without blocking. If the counter is not decremented, there is no effect and try_acquire immediately returns. An implementation by fail to decrement the counter even if it is positive. [ Note: This spurious failure is normally uncommon, but allows interesting implementations based on a simple compare and exchange ([atomic]). -- end note] An implementation should ensure that try_acquire() does not consistently return false in the absence of contending semaphore operations.“