Effects: Attempts to atomically decrement
counter if it is positive,
without blocking
. If
counter is not decremented, there is no effect and
try_acquire immediately returns
. An implementation may fail to decrement
counter
even if it is positive
. [
Note 1:
This spurious failure is normally uncommon, but
allows interesting implementations
based on a simple compare and exchange (
[atomics])
. —
end note]
An implementation should ensure that
try_acquire
does not consistently return
false
in the absence of contending semaphore operations
.