Effects: Attempts to obtain ownership of the mutex for the calling thread without
blocking
. If ownership is not obtained, there is no effect and
try_lock()
immediately returns
. An implementation may fail to obtain the lock even if it is not
held by any other thread
. [
Note 4:
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_lock() does not consistently return
false
in the absence of contending mutex acquisitions
.