[#BloombergLP-bsls-SpinLock-tryLock] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/SpinLock.adoc[SpinLock]::tryLock :relfileprefix: ../../../ :mrdocs: Attempt to acquire the lock, retrying up to `numRetries` times. == Synopsis Declared in `<bsls_spinlock.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int tryLock(int numRetries = 0); ---- == Description Attempt to acquire the lock; optionally specify the `numRetries` times to attempt again if this object is already locked. Return 0 on success, and a non‐zero value if the lock was not successfully acquired. The behavior is undefined unless `0 <= numRetries`. == Return Value 0 on success; non‐zero if the lock was not acquired == Parameters [cols="1,4"] |=== | Name| Description | *numRetries* | maximum additional attempts if the lock is held |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#